Skip to content

Commit

Permalink
update delegate/undelegate for 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenebelov committed Jan 17, 2025
1 parent c3c392b commit 91415bb
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions src/utils/cspr-network.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { RpcClient } from '../rpc';
import {
Args,
CLValue,
CLValueUInt512,
ContractCallBuilder,
NativeDelegateBuilder,
NativeRedelegateBuilder,
Expand Down Expand Up @@ -54,17 +57,20 @@ export class CasperNetwork {
}

if (contractHash) {
// need to provide contract hash
return (
new ContractCallBuilder()
.from(delegatorPublicKey)
.byHash(contractHash)
.entryPoint('delegate')
.chainName(networkName)
// .amount(amountMotes)
.ttl(ttl)
.buildFor1_5()
);
return new ContractCallBuilder()
.from(delegatorPublicKey)
.byHash(contractHash)
.entryPoint('delegate')
.chainName(networkName)
.runtimeArgs(
Args.fromMap({
validator: CLValue.newCLPublicKey(validatorPublicKey),
delegator: CLValue.newCLPublicKey(delegatorPublicKey),
amount: CLValueUInt512.newCLUInt512(amountMotes)
})
)
.ttl(ttl)
.buildFor1_5();
}

return new Error('Need to provide contract hash');
Expand All @@ -91,17 +97,20 @@ export class CasperNetwork {
}

if (contractHash) {
// need to provide contract hash
return (
new ContractCallBuilder()
.from(delegatorPublicKey)
.byHash(contractHash)
.entryPoint('undelegate')
.chainName(networkName)
// .amount(amountMotes)
.ttl(ttl)
.buildFor1_5()
);
return new ContractCallBuilder()
.from(delegatorPublicKey)
.byHash(contractHash)
.entryPoint('undelegate')
.chainName(networkName)
.ttl(ttl)
.runtimeArgs(
Args.fromMap({
validator: CLValue.newCLPublicKey(validatorPublicKey),
delegator: CLValue.newCLPublicKey(delegatorPublicKey),
amount: CLValueUInt512.newCLUInt512(amountMotes)
})
)
.buildFor1_5();
}

return new Error('Need to provide contract hash');
Expand Down

0 comments on commit 91415bb

Please sign in to comment.