@@ -132,6 +132,7 @@ import {
132132
133133import {
134134 CompletePayloadSignatureType ,
135+ CompletePayloadSignatureOperation ,
135136 COMPLETE_PAYLOAD_SIGNATURE ,
136137 CompletePayloadSignatureArgs ,
137138 CompletePayloadSignatureResult
@@ -2491,6 +2492,7 @@ export class Client {
24912492 this . requireFull ( )
24922493 const prepareMovementMovementParams = createPrepareMovementParams (
24932494 address ,
2495+ false ,
24942496 quantity ,
24952497 type
24962498 )
@@ -2506,6 +2508,7 @@ export class Client {
25062508
25072509 const movementPayloadParams = createAddMovementParams (
25082510 address ,
2511+ false ,
25092512 quantity ,
25102513 type ,
25112514 result . data . prepareMovement . nonce ,
@@ -2615,7 +2618,7 @@ export class Client {
26152618 data : approveAbi
26162619 } )
26172620 approveTx . getChainId = ( ) => chainId
2618- const approveSignature = await this . signEthTransaction ( approveTx )
2621+ const approveSignature = await this . signEthTransaction ( approveTx , CompletePayloadSignatureOperation . Transfer )
26192622 setEthSignature ( approveTx , approveSignature )
26202623 const p = await this . web3 . eth . sendSignedTransaction (
26212624 '0x' + approveTx . serialize ( ) . toString ( 'hex' )
@@ -2759,7 +2762,7 @@ export class Client {
27592762
27602763 ethTx . getChainId = ( ) => chainId
27612764
2762- const ethTxSignature = await this . signEthTransaction ( ethTx )
2765+ const ethTxSignature = await this . signEthTransaction ( ethTx , CompletePayloadSignatureOperation . Transfer )
27632766 setEthSignature ( ethTx , ethTxSignature )
27642767 const receipt = await this . web3 . eth . sendSignedTransaction (
27652768 '0x' + ethTx . serialize ( ) . toString ( 'hex' )
@@ -2811,7 +2814,7 @@ export class Client {
28112814 }
28122815 transaction . calculate ( balance )
28132816 const payload = transaction . serialize ( false )
2814- const signature = await this . signNeoPayload ( payload . toLowerCase ( ) )
2817+ const signature = await this . signNeoPayload ( payload . toLowerCase ( ) , CompletePayloadSignatureOperation . Transfer )
28152818 transaction . addWitness (
28162819 tx . Witness . fromSignature ( signature , childKey . public_key )
28172820 )
@@ -3005,7 +3008,7 @@ export class Client {
30053008 }
30063009 }
30073010
3008- private async signNeoPayload ( payload : string ) : Promise < string > {
3011+ private async signNeoPayload ( payload : string , operation : CompletePayloadSignatureOperation ) : Promise < string > {
30093012 const messageHash = u . sha256 ( payload )
30103013 const childKey = this . apiKey . child_keys [ BIP44 . NEO ]
30113014 const payloadPresig = await computePresig ( {
@@ -3021,6 +3024,7 @@ export class Client {
30213024 } )
30223025 const signature = await this . completePayloadSignature ( {
30233026 blockchain : Blockchain . NEO ,
3027+ operation,
30243028 payload,
30253029 public_key : childKey . public_key ,
30263030 signature : payloadPresig . presig ,
@@ -3033,7 +3037,7 @@ export class Client {
30333037 return signature
30343038 }
30353039
3036- private async signEthTransaction ( etx : EthTransaction ) : Promise < string > {
3040+ private async signEthTransaction ( etx : EthTransaction , operation : CompletePayloadSignatureOperation ) : Promise < string > {
30373041 const childKey = this . apiKey . child_keys [ BIP44 . ETH ]
30383042 const txSignature = await computePresig ( {
30393043 apiKey : {
@@ -3050,6 +3054,7 @@ export class Client {
30503054 const payload = serializeEthTx ( etx )
30513055 const invocationSignature = await this . completePayloadSignature ( {
30523056 blockchain : Blockchain . ETH ,
3057+ operation,
30533058 payload : payload . toLowerCase ( ) ,
30543059 public_key : childKey . public_key ,
30553060 signature : txSignature . presig ,
@@ -3162,6 +3167,7 @@ export class Client {
31623167 const prepareAMovement = async ( ) => {
31633168 const params = {
31643169 address,
3170+ backendGeneratedPayload : true ,
31653171 quantity : {
31663172 amount : bnAmount . toFormat (
31673173 8 ,
@@ -3184,6 +3190,8 @@ export class Client {
31843190 }
31853191
31863192 await prepareAMovement ( )
3193+ console . info ( "Prepared movement: " , preparedMovement )
3194+
31873195 let signedAddMovementPayload : PayloadSignature
31883196 let addMovementResult : GQLResp < {
31893197 addMovement : AddMovement
@@ -3192,6 +3200,7 @@ export class Client {
31923200 signedAddMovementPayload = await this . signPayload ( {
31933201 payload : {
31943202 address : childKey . address ,
3203+ backendGeneratedPayload : true ,
31953204 nonce : preparedMovement . nonce ,
31963205 quantity : {
31973206 amount : movementAmount . toFormat (
@@ -3223,6 +3232,7 @@ export class Client {
32233232 const sanitizedPayload = sanitizeAddMovementPayload (
32243233 signedAddMovementPayload . signedPayload as never
32253234 )
3235+ console . info ( "Sanitized add movement payload: " , sanitizedPayload )
32263236 try {
32273237 addMovementResult = await this . gql . mutate < {
32283238 addMovement : AddMovement
@@ -3261,9 +3271,12 @@ export class Client {
32613271 movementId : addMovementResult . data . addMovement . id . toString ( )
32623272 }
32633273 }
3274+ console . info ( "Add movement result: " , addMovementResult )
3275+ console . info ( "Signed add movement payload: " , signedAddMovementPayload )
32643276
32653277 const blockchainSignature = await this . completePayloadSignature ( {
32663278 blockchain : blockchain . toUpperCase ( ) as Blockchain ,
3279+ operation : movementType === MovementTypeDeposit ? CompletePayloadSignatureOperation . Deposit : CompletePayloadSignatureOperation . Withdrawal ,
32673280 payload : signedAddMovementPayload . blockchain_raw . toLowerCase ( ) ,
32683281 public_key : childKey . public_key ,
32693282 signature : signedAddMovementPayload . blockchain_data . userSig ,
@@ -3337,6 +3350,7 @@ export class Client {
33373350 unfinishedTransaction . blockchainSignature ||
33383351 ( await this . completePayloadSignature ( {
33393352 blockchain : blockchain . toUpperCase ( ) as Blockchain ,
3353+ operation : unfinishedTransaction . movement . type === MovementTypeDeposit ? CompletePayloadSignatureOperation . Deposit : CompletePayloadSignatureOperation . Withdrawal ,
33403354 payload : signedAddMovementPayload . blockchain_raw . toLowerCase ( ) ,
33413355 public_key : childKey . public_key ,
33423356 signature : signedAddMovementPayload . blockchain_data . userSig ,
@@ -3444,7 +3458,7 @@ export class Client {
34443458 } )
34453459 movementTx . getChainId = ( ) => chainId
34463460
3447- const invocationSignature = await this . signEthTransaction ( movementTx )
3461+ const invocationSignature = await this . signEthTransaction ( movementTx , movementType === MovementTypeDeposit ? CompletePayloadSignatureOperation . Deposit : CompletePayloadSignatureOperation . Withdrawal )
34483462
34493463 setEthSignature ( movementTx , invocationSignature )
34503464 const serializedEthTx = movementTx . serialize ( ) . toString ( 'hex' )
@@ -3544,7 +3558,7 @@ export class Client {
35443558 . calculate ( balance )
35453559 const payload = neoTransaction . serialize ( false )
35463560
3547- const signature = await this . signNeoPayload ( payload . toLowerCase ( ) )
3561+ const signature = await this . signNeoPayload ( payload . toLowerCase ( ) , movementType === MovementTypeDeposit ? CompletePayloadSignatureOperation . Deposit : CompletePayloadSignatureOperation . Withdrawal )
35483562 neoTransaction . addWitness (
35493563 tx . Witness . fromSignature ( signature , childKey . public_key )
35503564 )
@@ -3612,6 +3626,7 @@ export class Client {
36123626 ) : Promise < SignMovementResult > {
36133627 const signMovementParams = createAddMovementParams (
36143628 address ,
3629+ false ,
36153630 quantity ,
36163631 MovementTypeWithdrawal ,
36173632 nonce
0 commit comments