@@ -43,7 +43,7 @@ export class CasperNetwork {
43
43
amountMotes : string | BigNumber ,
44
44
deployCost : number ,
45
45
ttl : number ,
46
- contractHash ?: string
46
+ auctionContractHash ?: string
47
47
) {
48
48
if ( this . apiVersion === 2 ) {
49
49
new NativeDelegateBuilder ( )
@@ -56,10 +56,10 @@ export class CasperNetwork {
56
56
. build ( ) ;
57
57
}
58
58
59
- if ( contractHash ) {
59
+ if ( auctionContractHash ) {
60
60
return new ContractCallBuilder ( )
61
61
. from ( delegatorPublicKey )
62
- . byHash ( contractHash )
62
+ . byHash ( auctionContractHash )
63
63
. entryPoint ( 'delegate' )
64
64
. chainName ( networkName )
65
65
. runtimeArgs (
@@ -73,7 +73,9 @@ export class CasperNetwork {
73
73
. buildFor1_5 ( ) ;
74
74
}
75
75
76
- return new Error ( 'Need to provide contract hash' ) ;
76
+ return new Error (
77
+ 'Auction contract hash is required when creating a transaction on Casper Network 1.5.x'
78
+ ) ;
77
79
}
78
80
79
81
public createUndelegateTransaction (
@@ -83,7 +85,7 @@ export class CasperNetwork {
83
85
amountMotes : string | BigNumber ,
84
86
deployCost : number ,
85
87
ttl : number ,
86
- contractHash ?: string
88
+ auctionContractHash ?: string
87
89
) {
88
90
if ( this . apiVersion === 2 ) {
89
91
new NativeUndelegateBuilder ( )
@@ -96,10 +98,10 @@ export class CasperNetwork {
96
98
. build ( ) ;
97
99
}
98
100
99
- if ( contractHash ) {
101
+ if ( auctionContractHash ) {
100
102
return new ContractCallBuilder ( )
101
103
. from ( delegatorPublicKey )
102
- . byHash ( contractHash )
104
+ . byHash ( auctionContractHash )
103
105
. entryPoint ( 'undelegate' )
104
106
. chainName ( networkName )
105
107
. ttl ( ttl )
@@ -113,21 +115,25 @@ export class CasperNetwork {
113
115
. buildFor1_5 ( ) ;
114
116
}
115
117
116
- return new Error ( 'Need to provide contract hash' ) ;
118
+ return new Error (
119
+ 'Auction contract hash is required when creating a transaction on Casper Network 1.5.x'
120
+ ) ;
117
121
}
118
122
119
123
public createRedelegateTransaction (
120
124
delegatorPublicKey : PublicKey ,
121
125
validatorPublicKey : PublicKey ,
126
+ newValidatorPublicKey : PublicKey ,
122
127
networkName : string ,
123
128
amountMotes : string | BigNumber ,
124
129
deployCost : number ,
125
130
ttl : number ,
126
- contractHash ?: string
131
+ auctionContractHash ?: string
127
132
) {
128
133
if ( this . apiVersion === 2 ) {
129
134
new NativeRedelegateBuilder ( )
130
135
. validator ( validatorPublicKey )
136
+ . newValidator ( newValidatorPublicKey )
131
137
. from ( delegatorPublicKey )
132
138
. amount ( amountMotes )
133
139
. chainName ( networkName )
@@ -136,21 +142,31 @@ export class CasperNetwork {
136
142
. build ( ) ;
137
143
}
138
144
139
- if ( contractHash ) {
140
- // need to provide contract hash
141
- return (
142
- new ContractCallBuilder ( )
143
- . from ( delegatorPublicKey )
144
- . byHash ( contractHash )
145
- . entryPoint ( 'redelegate' )
146
- . chainName ( networkName )
147
- // .amount(amountMotes)
148
- . ttl ( ttl )
149
- . buildFor1_5 ( )
150
- ) ;
145
+ if ( auctionContractHash ) {
146
+ return new ContractCallBuilder ( )
147
+ . from ( delegatorPublicKey )
148
+ . byHash ( auctionContractHash )
149
+ . entryPoint ( 'redelegate' )
150
+ . chainName ( networkName )
151
+ . runtimeArgs (
152
+ Args . fromMap ( {
153
+ validator : CLValue . newCLPublicKey ( validatorPublicKey ) ,
154
+ delegator : CLValue . newCLPublicKey ( delegatorPublicKey ) ,
155
+ amount : CLValueUInt512 . newCLUInt512 ( amountMotes ) ,
156
+ ...( newValidatorPublicKey
157
+ ? {
158
+ new_validator : CLValue . newCLPublicKey ( newValidatorPublicKey )
159
+ }
160
+ : { } )
161
+ } )
162
+ )
163
+ . ttl ( ttl )
164
+ . buildFor1_5 ( ) ;
151
165
}
152
166
153
- return new Error ( 'Need to provide contract hash' ) ;
167
+ return new Error (
168
+ 'Auction contract hash is required when creating a transaction on Casper Network 1.5.x'
169
+ ) ;
154
170
}
155
171
156
172
public createTransferTransaction (
@@ -185,7 +201,9 @@ export class CasperNetwork {
185
201
return await this . rpcClient . putDeploy ( deploy ) ;
186
202
}
187
203
188
- return Promise . reject ( 'Transaction does not have a deploy' ) ;
204
+ return Promise . reject (
205
+ 'Legacy deploy transaction is required when submitting to Casper Network 1.5'
206
+ ) ;
189
207
}
190
208
191
209
public async getTransaction ( hash : TransactionHash ) {
@@ -195,12 +213,16 @@ export class CasperNetwork {
195
213
hash . transactionV1 ?. toHex ( )
196
214
) ;
197
215
}
216
+
217
+ if ( hash . deploy ) {
218
+ return await this . rpcClient . getTransactionByDeployHash (
219
+ hash . deploy . toHex ( )
220
+ ) ;
221
+ }
198
222
}
199
223
200
224
if ( hash . deploy ) {
201
- return await this . rpcClient . getTransactionByDeployHash (
202
- hash . deploy . toHex ( )
203
- ) ;
225
+ return await this . rpcClient . getDeploy ( hash . deploy . toHex ( ) ) ;
204
226
}
205
227
206
228
return Promise . reject ( 'Hash is not valid' ) ;
0 commit comments