UNPKG

leap-node

Version:

[![codecov](https://codecov.io/gh/leapdao/leap-node/branch/master/graph/badge.svg)](https://codecov.io/gh/leapdao/leap-node) [![Docker Repository on Quay](https://quay.io/repository/leapdao/leap-node/status "Docker Repository on Quay")](https://quay.io/re

755 lines (690 loc) 73.1 kB
const { Tx, Input, Outpoint, Output } = require('leap-core'); const utils = require('ethereumjs-util'); const ethers = require('ethers'); // eslint-disable-line import/no-extraneous-dependencies const checkSpendCond = require('./checkSpendCond'); const makeFlags = require('../../flags'); const { NFT_COLOR_BASE, NST_COLOR_BASE, } = require('../../api/methods/constants'); const Web3 = require('web3'); const checkSpendingCondition = require('./../../api/methods/checkSpendingCondition'); const erc20Tokens = [ '0x1111111111111111111111111111111111111111', '0x2222222222222222222222222222222222222222', ]; const erc1948Tokens = [ '0x3333333333333333333333333333333333333333', '0x4444444444444444444444444444444444444444', ]; const erc721Tokens = [ '0x5555555555555555555555555555555555555555', '0x6666666666666666666666666666666666666666', ]; const bridgeState = { tokens: { erc20: erc20Tokens, erc721: erc721Tokens, erc1948: erc1948Tokens, }, networkId: 218508104, blockHeight: 123, minGasPrices: [100], logsCache: {}, web3: new Web3(), }; bridgeState.flags = makeFlags(bridgeState, { spend_cond_new_bytecode: 1000, }); const NFTCondition = '6080604052348015600f57600080fd5b5060043610602b5760e060020a6000350463d01a81e181146030575b600080fd5b605960048036036040811015604457600080fd5b50600160a060020a038135169060200135605b565b005b6040805160e060020a6323b872dd028152306004820152600160a060020a03841660248201526044810183905290517311111111111111111111111111111111111111119182916323b872dd9160648082019260009290919082900301818387803b15801560c857600080fd5b505af115801560db573d6000803e3d6000fd5b5050505050505056fea165627a7a723058206e658cc8b44fd3d32eef8c4222a0f8773e93bc6efa0fb08e4db77979dacc9e790029'; const ErrorCondition = '6080604052348015600f57600080fd5b5060043610602b5760e060020a6000350463d01a81e181146030575b600080fd5b605960048036036040811015604457600080fd5b50600160a060020a038135169060200135605b565b005b6040805160e560020a62461bcd028152602060048201526005602482015260d960020a6432b93937b902604482015290519081900360640190fdfea165627a7a7230582075dba245d93b438fceee346da19c502033c7def2a2ad830b0f9bb0f87ef2d53f0029'; const NSTCondition = '6080604052348015600f57600080fd5b5060043610602b5760e060020a6000350463d3b7576c81146030575b600080fd5b605060048036036040811015604457600080fd5b50803590602001356052565b005b6040805160e060020a63a983d43f0281526004810184905260248101839052905173111111111111111111111111111111111111111191829163a983d43f9160448082019260009290919082900301818387803b15801560b157600080fd5b505af115801560c4573d6000803e3d6000fd5b5050505050505056fea165627a7a723058209d7c918824f80651fee7b4f8b99ed305e72e70fad4ff09430ebab4adf0eed3d40029'; const NstSigWriteCondition = '608060405234801561001057600080fd5b506004361061002e5760e060020a6000350463bff19ba68114610033575b600080fd5b6100e36004803603606081101561004957600080fd5b813591602081013591810190606081016040820135602060020a81111561006f57600080fd5b82018360208201111561008157600080fd5b803590602001918460018302840111602060020a831117156100a257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506100ff945050505050565b60408051600160a060020a039092168252519081900360200190f35b60405160e060020a6336c9c45702815260048101848152602482018490526060604483019081528351606484015283516000937334511111111111111111111111111111111113459384936336c9c457938a938a938a93909290916084019060208501908083838e5b83811015610180578181015183820152602001610168565b50505050905090810190601f1680156101ad5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156101ce57600080fd5b505af11580156101e2573d6000803e3d6000fd5b5050505080600160a060020a0316636352211e866040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561022d57600080fd5b505afa158015610241573d6000803e3d6000fd5b505050506040513d602081101561025757600080fd5b50519594505050505056fea165627a7a7230582003b4339bbe926e1f5a8e601b408a7765a2b41a60455b8987677dbc63e2c4d4de0029'; const MultiCondition = '608060405234801561001057600080fd5b506004361061002e5760e060020a60003504635bac6c1e8114610033575b600080fd5b6100656004803603606081101561004957600080fd5b5080359060208101359060400135600160a060020a0316610067565b005b6040805160e060020a63a983d43f0281526004810185905260248101849052905173333333333333333333333333333333333333333391829163a983d43f9160448082019260009290919082900301818387803b1580156100c757600080fd5b505af11580156100db573d6000803e3d6000fd5b50506040805160e060020a6323b872dd028152306004820152600160a060020a038616602482015260448101889052905173555555555555555555555555555555555555555593508392506323b872dd9160648082019260009290919082900301818387803b15801561014d57600080fd5b505af1158015610161573d6000803e3d6000fd5b50506040805160e060020a6370a082310281523060048201529051731111111111111111111111111111111111111111935083925063a9059cbb91879184916370a08231916024808301926020929190829003018186803b1580156101c557600080fd5b505afa1580156101d9573d6000803e3d6000fd5b505050506040513d60208110156101ef57600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561023e57600080fd5b505af1158015610252573d6000803e3d6000fd5b505050506040513d602081101561026857600080fd5b50506040805160e060020a6370a08231028152306004820152905173222222222222222222222222222222222222222291829163a9059cbb91889184916370a08231916024808301926020929190829003018186803b1580156102ca57600080fd5b505afa1580156102de573d6000803e3d6000fd5b505050506040513d60208110156102f457600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561034357600080fd5b505af1158015610357573d6000803e3d6000fd5b505050506040513d602081101561036d57600080fd5b50505050505050505056fea165627a7a723058207e221fd58b2d5943b615bc77011474e47caa90f6b686409991d704d015ebec9c0029'; const MultiConditionAllowance = '608060405234801561001057600080fd5b506004361061002e5760e060020a60003504635bac6c1e8114610033575b600080fd5b6100656004803603606081101561004957600080fd5b5080359060208101359060400135600160a060020a0316610067565b005b6040805160e060020a6323b872dd028152600160a060020a03831660048201523060248201526044810185905290517355555555555555555555555555555555555555559182916323b872dd9160648082019260009290919082900301818387803b1580156100d557600080fd5b505af11580156100e9573d6000803e3d6000fd5b50506040805160e160020a636eb1769f028152600160a060020a03861660048201523060248201529051731111111111111111111111111111111111111111935060009250839163dd62ed3e916044808301926020929190829003018186803b15801561015557600080fd5b505afa158015610169573d6000803e3d6000fd5b505050506040513d602081101561017f57600080fd5b50516040805160e060020a6323b872dd028152600160a060020a038781166004830152306024830152604482018490529151929350908416916323b872dd916064808201926020929091908290030181600087803b1580156101e057600080fd5b505af11580156101f4573d6000803e3d6000fd5b505050506040513d602081101561020a57600080fd5b50506040805160e160020a636eb1769f028152600160a060020a0386166004820152306024820152905173222222222222222222222222222222222222222291829163dd62ed3e91604480820192602092909190829003018186803b15801561027257600080fd5b505afa158015610286573d6000803e3d6000fd5b505050506040513d602081101561029c57600080fd5b50516040805160e060020a6323b872dd028152600160a060020a038881166004830152306024830152604482018490529151929450908316916323b872dd916064808201926020929091908290030181600087803b1580156102fd57600080fd5b505af1158015610311573d6000803e3d6000fd5b505050506040513d602081101561032757600080fd5b50505050505050505056fea165627a7a723058206b2d9289ffe41ef706d920793144e5ddec39d3c8d74ef8bd4bf51ea02837a3fb0029'; const BreedingCondition = '6080604052348015600f57600080fd5b5060043610602b5760e060020a6000350463451da9f981146030575b600080fd5b605f60048036036060811015604457600080fd5b50803590600160a060020a0360208201351690604001356061565b005b6040805160e060020a63451da9f902815260048101859052600160a060020a038416602482015260448101839052905173333333333333333333333333333333333333333391829163451da9f99160648082019260009290919082900301818387803b15801560cf57600080fd5b505af115801560e2573d6000803e3d6000fd5b505050505050505056fea165627a7a7230582022038a27f6c269784e06d5e8dd55f5d146448b90cc1c08599f7160b1bc79c7390029'; const GameCondition = '608060405234801561001057600080fd5b506004361061002e5760e060020a6000350463ab66bead8114610033575b600080fd5b6100656004803603608081101561004957600080fd5b508035906020810135906040810135906060013560ff16610067565b005b60006100758583868661054c565b905060606100a27f2345222222222222222222222222222222222222222222222222222222222222610612565b905060606100af87610612565b905060006100bd8383610677565b90506100c9838361074e565b151561011a576040805160e560020a62461bcd0281526020600482015260156024820152605860020a74706c617965722068616e6473206e6f742073616d6502604482015290519081900360640190fd5b6040805160e060020a6370a0823102815230600482015290517312341111111111111111111111111111111111119160009183916370a08231916024808301926020929190829003018186803b15801561017357600080fd5b505afa158015610187573d6000803e3d6000fd5b505050506040513d602081101561019d57600080fd5b50516040805160e060020a6323b872dd028152600160a060020a0389811660048301523060248301526005840460448301529151929350908416916323b872dd916064808201926020929091908290030181600087803b15801561020057600080fd5b505af1158015610214573d6000803e3d6000fd5b505050506040513d602081101561022a57600080fd5b50506040805160e060020a6370a082310281523060048201529051600160a060020a038416916370a08231916024808301926020929190829003018186803b15801561027557600080fd5b505afa158015610289573d6000803e3d6000fd5b505050506040513d602081101561029f57600080fd5b50519050821515610441576040805160e060020a63a9059cbb02815273345633333333333333333333333333333333333360048201526005600684040260248201529051600160a060020a0384169163a9059cbb9160448083019260209291908290030181600087803b15801561031557600080fd5b505af1158015610329573d6000803e3d6000fd5b505050506040513d602081101561033f57600080fd5b50506040805160e060020a6370a082310281523060048201529051600160a060020a038416916370a08231916024808301926020929190829003018186803b15801561038a57600080fd5b505afa15801561039e573d6000803e3d6000fd5b505050506040513d60208110156103b457600080fd5b50516040805160e060020a63a9059cbb028152600160a060020a0389811660048301526024820184905291519293509084169163a9059cbb916044808201926020929091908290030181600087803b15801561040f57600080fd5b505af1158015610423573d6000803e3d6000fd5b505050506040513d602081101561043957600080fd5b506105409050565b82600214156104ad5781600160a060020a031663a9059cbb87836040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561040f57600080fd5b6040805160e060020a63a9059cbb0281527334563333333333333333333333333333333333336004820152602481018390529051600160a060020a0384169163a9059cbb9160448083019260209291908290030181600087803b15801561051357600080fd5b505af1158015610527573d6000803e3d6000fd5b505050506040513d602081101561053d57600080fd5b50505b50505050505050505050565b6000808560405160200180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182815260200191505060405160208183030381529060405280519060200120905060018186868660405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156105fd573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b60408051600a8082526101608201909252606091602082016101408038833901905050905060005b600a81101561067157815161ffff6010830260020a8504169083908390811061065f57fe5b6020908102909101015260010161063a565b50919050565b60008080805b600581101561072157848181518110151561069457fe5b9060200190602002015186600583018151811015156106af57fe5b90602001906020020151116106c55760006106c8565b60015b60ff168301925085600582018151811015156106e057fe5b9060200190602002015185828151811015156106f857fe5b906020019060200201511161070e576000610711565b60015b60ff16919091019060010161067d565b5080821161073f5780821061073757600061073a565b60025b610742565b60015b60ff1695945050505050565b6000606061075b84610803565b9050606061076884610803565b905060005b60058110156107f757818181518110151561078457fe5b90602001906020020151838281518110151561079c57fe5b60209081029091010151146107ef576040805160e560020a62461bcd02815260206004820152600e6024820152609060020a6d68616e6473206e6f742073616d6502604482015290519081900360640190fd5b60010161076d565b50600195945050505050565b60606108128260006004610816565b5090565b81818082141561082757505061094f565b600085600286860305860181518110151561083e57fe5b9060200190602002015190505b818313610925575b80868481518110151561086257fe5b90602001906020020151101561087d57600190920191610853565b858281518110151561088b57fe5b906020019060200201518110156108a8576000199091019061087d565b8183136109205785828151811015156108bd57fe5b9060200190602002015186848151811015156108d557fe5b9060200190602002015187858151811015156108ed57fe5b906020019060200201888581518110151561090457fe5b6020908102909101019190915252600190920191600019909101905b61084b565b8185121561093857610938868684610816565b8383121561094b5761094b868486610816565b5050505b50505056fea165627a7a72305820fff8bc5e39ef79a391122b4afc041e9298095e7f3440832ac3c04f95ce445e6a0029'; const EarthContractOld = '608060405234801561001057600080fd5b50600436106100395760e060020a6000350463135b4234811461003e5780634691486a1461010a575b600080fd5b610108600480360360c081101561005457600080fd5b813591602081013591810190606081016040820135602060020a81111561007a57600080fd5b82018360208201111561008c57600080fd5b803590602001918460018302840111602060020a831117156100ad57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050823593505050602081013563ffffffff169060400135600160a060020a03166101c3565b005b6101086004803603606081101561012057600080fd5b813591600160a060020a0360208201351691810190606081016040820135602060020a81111561014f57600080fd5b82018360208201111561016157600080fd5b803590602001918460018302840111602060020a8311171561018257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506106dc945050505050565b6040805160e060020a6337ebbc030281526004810188905290517334511111111111111111111111111111111113459160009183916337ebbc03916024808301926020929190829003018186803b15801561021d57600080fd5b505afa158015610231573d6000803e3d6000fd5b505050506040513d602081101561024757600080fd5b50516040805160e160020a6331a9108f028152600481018b905290519192508289039173234111111111111111111111111111111111123491829163a9059cbb91600160a060020a03881691636352211e91602480820192602092909190829003018186803b1580156102b957600080fd5b505afa1580156102cd573d6000803e3d6000fd5b505050506040513d60208110156102e357600080fd5b50516040805160e060020a63ffffffff8516028152600160a060020a039092166004830152602482018690525160448083019260209291908290030181600087803b15801561033157600080fd5b505af1158015610345573d6000803e3d6000fd5b505050506040513d602081101561035b57600080fd5b50506040805160e160020a6331a9108f028152600481018990529051600160a060020a038084169263a9059cbb9291881691636352211e91602480820192602092909190829003018186803b1580156103b357600080fd5b505afa1580156103c7573d6000803e3d6000fd5b505050506040513d60208110156103dd57600080fd5b50516040805163ffffffff84811660e060020a028252600160a060020a039093166004820152918a1660248301525160448083019260209291908290030181600087803b15801561042d57600080fd5b505af1158015610441573d6000803e3d6000fd5b505050506040513d602081101561045757600080fd5b505060405160e060020a6336c9c457028152600481018b8152602482018b90526060604483019081528a5160648401528a51600160a060020a038816936336c9c457938f938f938f9360840190602085019080838360005b838110156104c75781810151838201526020016104af565b50505050905090810190601f1680156104f45780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561051557600080fd5b505af1158015610529573d6000803e3d6000fd5b50505050600084600160a060020a03166337ebbc03896040518263ffffffff1660e060020a0281526004018082815260200191505060206040518083038186803b15801561057657600080fd5b505afa15801561058a573d6000803e3d6000fd5b505050506040513d60208110156105a057600080fd5b50516040805160e060020a63a983d43f028152600481018b905263ffffffff8a16830160248201529051919250600160a060020a0387169163a983d43f9160448082019260009290919082900301818387803b1580156105ff57600080fd5b505af1158015610613573d6000803e3d6000fd5b50505050606483118061062c575060648763ffffffff16115b156106cf576040805160e060020a63a9059cbb028152600160a060020a038816600482015263ffffffff891685016024820152905173123111111111111111111111111111111111112391829163a9059cbb916044808201926020929091908290030181600087803b1580156106a157600080fd5b505af11580156106b5573d6000803e3d6000fd5b505050506040513d60208110156106cb57600080fd5b5050505b5050505050505050505050565b60006106fe6001606060020a0319606060020a3002168363ffffffff61080b16565b9050600160a060020a0381167356711111111111111111111111111111111115671461076f576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb028152600160a060020a038516600482015260248101869052905173123111111111111111111111111111111111112391829163a9059cbb916044808201926020929091908290030181600087803b1580156107d857600080fd5b505af11580156107ec573d6000803e3d6000fd5b505050506040513d602081101561080257600080fd5b50505050505050565b6000806000808451604114151561082857600093505050506108dd565b50505060208201516040830151606084015160001a601b60ff8216101561084d57601b015b8060ff16601b1415801561086557508060ff16601c14155b1561087657600093505050506108dd565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa1580156108cd573d6000803e3d6000fd5b5050506020604051035193505050505b9291505056fea165627a7a72305820be4c6feb172952fa9de64d69ce86e75a0153177130110dab8f3139ea7da09cb40029'; const EarthContract = '608060405234801561001057600080fd5b50600436106100445760e060020a60003504635ca740ab811461004957806394d615b514610086578063d4349137146100b8575b600080fd5b6100846004803603608081101561005f57600080fd5b50600160a060020a038135169060ff602082013516906040810135906060013561017f565b005b6100846004803603608081101561009c57600080fd5b5080359060ff6020820135169060408101359060600135610350565b610084600480360360c08110156100ce57600080fd5b813591602081013591810190606081016040820135602060020a8111156100f457600080fd5b82018360208201111561010657600080fd5b803590602001918460018302840111602060020a8311171561012757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050600160a060020a036020830135811692604001351690506104cb565b6040805160008152602080820180845230905260ff861682840152606082018590526080820184905291517356711111111111111111111111111111111115679260019260a080820193601f1981019281900390910190855afa1580156101ea573d6000803e3d6000fd5b50505060206040510351600160a060020a031614151561024f576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a08231028152306004820181905291518692600160a060020a0384169263a9059cbb9284916370a08231916024808301926020929190829003018186803b1580156102a457600080fd5b505afa1580156102b8573d6000803e3d6000fd5b505050506040513d60208110156102ce57600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561031d57600080fd5b505af1158015610331573d6000803e3d6000fd5b505050506040513d602081101561034757600080fd5b50505050505050565b604080516000815260208082018084523060a060020a890217905260ff861682840152606082018590526080820184905291517356711111111111111111111111111111111115679260019260a081810193601f1981019281900390910190855afa1580156103c3573d6000803e3d6000fd5b50505060206040510351600160a060020a0316141515610428576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb02815273456111111111111111111111111111111111145660048201526024810186905290517312311111111111111111111111111111111111239163a9059cbb9160448083019260209291908290030181600087803b15801561049957600080fd5b505af11580156104ad573d6000803e3d6000fd5b505050506040513d60208110156104c357600080fd5b505050505050565b81816104d5610d8c565b604080516080810180835260e160020a6331a9108f029052608481018b905290518190600160a060020a03861690636352211e9060a480850191602091818703018186803b15801561052657600080fd5b505afa15801561053a573d6000803e3d6000fd5b505050506040513d602081101561055057600080fd5b5051600160a060020a03908116825260006020838101919091526040805160e060020a6337ebbc03028152600481018f905281519190940193928816926337ebbc03926024808301939192829003018186803b1580156105af57600080fd5b505afa1580156105c3573d6000803e3d6000fd5b505050506040513d60208110156105d957600080fd5b50518152600060209091015290506105ef610d8c565b604080516080810180835260e160020a6331a9108f0290526084810189905290518190600160a060020a03861690636352211e9060a480850191602091818703018186803b15801561064057600080fd5b505afa158015610654573d6000803e3d6000fd5b505050506040513d602081101561066a57600080fd5b5051600160a060020a03908116825260006020838101919091526040805160e060020a6337ebbc03028152600481018d905281519190940193928816926337ebbc03926024808301939192829003018186803b1580156106c957600080fd5b505afa1580156106dd573d6000803e3d6000fd5b505050506040513d60208110156106f357600080fd5b50518152600060209091015280518351919250600160a060020a0390811691161415610769576040805160e560020a62461bcd02815260206004820152601a60248201527f63616e206e6f742074726164652077697468206f6e6573656c66000000000000604482015290519081900360640190fd5b604082015173234111111111111111111111111111111111123490731231111111111111111111111111111111111123908b0363ffffffff16600081116107eb576040805160e560020a62461bcd02815260206004820152600b602482015260a860020a6a656d70747920747261646502604482015290519081900360640190fd5b66038d7ea4c680008102606086018190526703782dace9d900001015610851576040805160e560020a62461bcd0281526020600482015260106024820152608160020a6f34b73b30b634b21032b6b4b9b9b4b7b702604482015290519081900360640190fd5b6040850151602060020a90819004908d040360008111156108c857600181146108ba576040805160e560020a62461bcd0281526020600482015260106024820152608260020a6f1a5b98dbdc9c9958dd081cda59db985b02604482015290519081900360640190fd5b606482600160208901520491505b87600160a060020a03166336c9c4578f8f8f6040518463ffffffff1660e060020a0281526004018084815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561093557818101518382015260200161091d565b50505050905090810190601f1680156109625780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561098357600080fd5b505af1158015610997573d6000803e3d6000fd5b505086516040805160e160020a636eb1769f028152600160a060020a039283166004820152306024820152905160009450918816925063dd62ed3e916044808301926020929190829003018186803b1580156109f257600080fd5b505afa158015610a06573d6000803e3d6000fd5b505050506040513d6020811015610a1c57600080fd5b50511160208681019190915286015180610a37575084602001515b610a415781610a46565b606482025b60608601819052604080870151815160e060020a63a983d43f028152600481018f90529201602483015251600160a060020a0389169163a983d43f91604480830192600092919082900301818387803b158015610aa257600080fd5b505af1158015610ab6573d6000803e3d6000fd5b50505060608601805166038d7ea4c68000908102909152600060408901528751930292600160a060020a038616915063a9059cbb90610af6858a8a610d1c565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015610b4857600080fd5b505af1158015610b5c573d6000803e3d6000fd5b505050506040513d6020811015610b7257600080fd5b50508451600160a060020a0385169063a9059cbb90610b9285898b610d1c565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015610be457600080fd5b505af1158015610bf8573d6000803e3d6000fd5b505050506040513d6020811015610c0e57600080fd5b5050606080860151908701516040805160e060020a63a9059cbb02815273456111111111111111111111111111111111145660048201529190920160248201529051600160a060020a0385169163a9059cbb9160448083019260209291908290030181600087803b158015610c8257600080fd5b505af1158015610c96573d6000803e3d6000fd5b505050506040513d6020811015610cac57600080fd5b50508451865160208089015181890151604080519215158352901515928201929092528151600160a060020a0394851694909316927f2d476ce15822194d3b3e6deb5bb7edd748b0f8ac84d26685f9d2991220c40b4f929181900390910190a35050505050505050505050505050565b6000839050816060015183606001511115610d375750600a83025b816060015183606001511415610d82578383606001511415610d595750600383025b816020015115158360200151151514158015610d7757506040830151155b15610d825750600a83025b6032029392505050565b6040805160808101825260008082526020820181905291810182905260608101919091529056fea165627a7a72305820c35f51757c326ca289e2fcdcab7cbde4fd154e8dca30256194a96be34a6977770029'; const AirContract = '608060405234801561001057600080fd5b50600436106100445760e060020a600035046329968bdd81146100495780639abc2cc8146100f6578063c521fbac14610119575b600080fd5b6100f46004803603604081101561005f57600080fd5b81359190810190604081016020820135602060020a81111561008057600080fd5b82018360208201111561009257600080fd5b803590602001918460018302840111602060020a831117156100b357600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101bd945050505050565b005b6100f46004803603604081101561010c57600080fd5b50803590602001356102f6565b6100f46004803603602081101561012f57600080fd5b810190602081018135602060020a81111561014957600080fd5b82018360208201111561015b57600080fd5b803590602001918460018302840111602060020a8311171561017c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610686945050505050565b60006101df6001606060020a0319606060020a3002168363ffffffff6107f416565b9050600160a060020a03811673567111111111111111111111111111111111156714610250576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a63a9059cbb028152734561111111111111111111111111111111111456600482015260248101859052905173123111111111111111111111111111111111112391829163a9059cbb916044808201926020929091908290030181600087803b1580156102c457600080fd5b505af11580156102d8573d6000803e3d6000fd5b505050506040513d60208110156102ee57600080fd5b505050505050565b6040805160e160020a6331a9108f028152600481018390529051733451111111111111111111111111111111111345916000918391636352211e916024808301926020929190829003018186803b15801561035057600080fd5b505afa158015610364573d6000803e3d6000fd5b505050506040513d602081101561037a57600080fd5b50516040805160e160020a636eb1769f028152600160a060020a0383166004820152306024820152905191925073234111111111111111111111111111111111123491600091839163dd62ed3e91604480820192602092909190829003018186803b1580156103e857600080fd5b505afa1580156103fc573d6000803e3d6000fd5b505050506040513d602081101561041257600080fd5b5051905085811015610466576040805160e560020a62461bcd0281526020600482015260126024820152607260020a711b9bc8199d5b991cc8185b1b1bd8d85d195902604482015290519081900360640190fd5b6040805160e060020a6323b872dd028152600160a060020a038581166004830152306024830152604482018990529151918416916323b872dd916064808201926020929091908290030181600087803b1580156104c257600080fd5b505af11580156104d6573d6000803e3d6000fd5b505050506040513d60208110156104ec57600080fd5b50506040805160e060020a6337ebbc03028152600481018790529051600091600160a060020a038716916337ebbc0391602480820192602092909190829003018186803b15801561053c57600080fd5b505afa158015610550573d6000803e3d6000fd5b505050506040513d602081101561056657600080fd5b50519050600160a060020a03851663a983d43f87610584848b6108cc565b6040518363ffffffff1660e060020a0281526004018083815260200182815260200192505050600060405180830381600087803b1580156105c457600080fd5b505af11580156105d8573d6000803e3d6000fd5b50506040805160e060020a63a9059cbb0281527345611111111111111111111111111111111114566004820152602481018b90529051731231111111111111111111111111111111111123935083925063a9059cbb916044808201926020929091908290030181600087803b15801561065057600080fd5b505af1158015610664573d6000803e3d6000fd5b505050506040513d602081101561067a57600080fd5b50505050505050505050565b60006106a86001606060020a0319606060020a3002168363ffffffff6107f416565b9050600160a060020a03811673567111111111111111111111111111111111156714610719576040805160e560020a62461bcd0281526020600482015260156024820152605b60020a740e6d2cedccae440c8decae640dcdee840dac2e8c6d02604482015290519081900360640190fd5b6040805160e060020a6370a0823102815230600482015290517312311111111111111111111111111111111111239160009183916370a08231916024808301926020929190829003018186803b15801561077257600080fd5b505afa158015610786573d6000803e3d6000fd5b505050506040513d602081101561079c57600080fd5b50516040805160e060020a63a9059cbb028152306004820152602481018390529051919250600160a060020a0384169163a9059cbb916044808201926020929091908290030181600087803b1580156102c457600080fd5b6000806000808451604114151561081157600093505050506108c6565b50505060208201516040830151606084015160001a601b60ff8216101561083657601b015b8060ff16601b1415801561084e57508060ff16601c14155b1561085f57600093505050506108c6565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa1580156108b6573d6000803e3d6000fd5b5050506020604051035193505050505b92915050565b6000806108d884610958565b905082810163ffffffff80831690821611610932576040805160e560020a62461bcd02815260206004820152600f6024820152608860020a6e627566666572206f766572666c6f7702604482015290519081900360640190fd5b602060020a63ffffffff9091160267ffffffff0000000019909416939093179392505050565b602060020a90049056fea165627a7a723058205bb8b7dd29a179195c96a27fd875d73cfdcb1168bf7bc87b079bd0810629c23a0029'; function replaceAll(str, find, replace) { return str.replace(new RegExp(find, 'g'), replace.replace('0x', '')); } const ADDR_1 = '0x4436373705394267350db2c06613990d34621d69'; const PRIV_1 = '0xad8e31c8862f5f86459e7cca97ac9302c5e1817077902540779eef66e21f394a'; const ADDR_2 = '0xF3beAC30C498D9E26865F34fCAa57dBB935b0D74'; const PRIV_2 = '0x278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'; const ADDR_3 = '0xE10f3D125e5f4C753A6456fc37123CF17C6900f2'; /* pragma solidity ^0.5.2; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; contract SpendingCondition { address constant tokenAddr = 0x1111111111111111111111111111111111111111; function fulfil( address _receiver, // output uint256 _amount // output ) public { // do transfer IERC20 token = IERC20(tokenAddr); uint256 diff = token.balanceOf(address(this)) - _amount; token.transfer(_receiver, _amount); if (diff > 0) { token.transfer(address(this), diff); } } } */ const conditionScript = Buffer.from( '608060405234801561001057600080fd5b506004361061002e5760e060020a6000350463d01a81e18114610033575b600080fd5b61005f6004803603604081101561004957600080fd5b50600160a060020a038135169060200135610061565b005b6040805160e060020a6370a08231028152306004820152905173111111111111111111111111111111111111111191600091849184916370a0823191602480820192602092909190829003018186803b1580156100bd57600080fd5b505afa1580156100d1573d6000803e3d6000fd5b505050506040513d60208110156100e757600080fd5b50516040805160e060020a63a9059cbb028152600160a060020a03888116600483015260248201889052915193909203935084169163a9059cbb916044808201926020929091908290030181600087803b15801561014457600080fd5b505af1158015610158573d6000803e3d6000fd5b505050506040513d602081101561016e57600080fd5b505060008111156101f8576040805160e060020a63a9059cbb028152306004820152602481018390529051600160a060020a0384169163a9059cbb9160448083019260209291908290030181600087803b1580156101cb57600080fd5b505af11580156101df573d6000803e3d6000fd5b505050506040513d60208110156101f557600080fd5b50505b5050505056fea165627a7a72305820b6375cb3c7f659844afea0adf999ea78d73fd047f5823fbe1447f8051fe0189b0029', 'hex' ); // PRIV matches spenderAddr hardcoded in script // const PRIV = // '0x94890218f2b0d04296f30aeafd13655eba4c5bbf1770273276fee52cbe3f2cb4'; async function expectToThrow(func, msg, args) { let err; if (Array.isArray(msg)) { // eslint-disable-next-line no-param-reassign args = msg; // eslint-disable-next-line no-param-reassign msg = ''; } try { await func(...args); } catch (e) { err = e; } if (!err) { throw new Error('expected to throw'); } if (err.return && Buffer.isBuffer(err.return) && err.return.length === 0) { err.return = ''; } if (err.return && err.return !== msg) { throw new Error(`expected ${msg}, but received ${err.return}`); } } describe('checkSpendCond', () => { test('valid tx', async () => { // a deposit to the above script has been done const scriptHash = utils.ripemd160(conditionScript); const deposit = Tx.deposit( 123, 5000000000, `0x${scriptHash.toString('hex')}`, // LEAP 0 ); const deposit2 = Tx.deposit( 1204, 7000000000, `0x${scriptHash.toString('hex')}`, // LEAP 0 ); const state = { unspent: { [new Outpoint(deposit.hash(), 0).hex()]: deposit.outputs[0].toJSON(), [new Outpoint(deposit2.hash(), 3).hex()]: deposit2.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const receiver = Buffer.from( '9999999999999999999999999999999999999999', 'hex' ); const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(deposit2.hash(), 3), script: conditionScript, }), new Input({ prevout: new Outpoint(deposit.hash(), 0), }), ], [ new Output(3007923300, `0x${scriptHash.toString('hex')}`, 0), new Output(1992076700, `0x${receiver.toString('hex')}`, 0), // gas change new Output( 6989874974, deposit2.outputs[0].address, deposit2.outputs[0].color ), ] ); // msgData that satisfies the spending condition const amountBuf = utils.setLengthLeft(utils.toBuffer(1992076700), 32); const msgData = '0xd01a81e1' + // function called `000000000000000000000000${receiver.toString('hex')}${amountBuf.toString( 'hex' )}`; // outputs condition.inputs[0].setMsgData(msgData); await checkSpendCond(state, condition, bridgeState); await checkSpendCond(state, condition, bridgeState, { network: { noSpendingConditions: false }, }); expect( checkSpendCond(state, condition, bridgeState, { network: { noSpendingConditions: true }, }) ).rejects.toEqual( new Error('Spending Conditions are not supported on this network') ); // check the checkSpendingCondition API call condition.signAll(PRIV_1); bridgeState.currentState = state; let apiResult = await checkSpendingCondition(bridgeState, condition.hex()); expect(apiResult.outputs).toEqual(condition.outputs); // test the error-case const outs = condition.outputs; condition.outputs = []; condition.signAll(PRIV_1); apiResult = await checkSpendingCondition(bridgeState, condition.hex()); expect(apiResult.outputs).toEqual(outs); expect( apiResult.error.startsWith('outputs do not match computation results') ).toEqual(true); }); test('Spending Condition: NFT', async () => { const nftAddr = erc721Tokens[0]; const script = Buffer.from( NFTCondition.replace( '1111111111111111111111111111111111111111', nftAddr.replace('0x', '') ), 'hex' ); const scriptHash = utils.ripemd160(script); const NFTDeposit = Tx.deposit( 123, // depositId nftAddr, `0x${scriptHash.toString('hex')}`, // owner (spending condition) NFT_COLOR_BASE ); const leapDeposit = Tx.deposit( 1230, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); const state = { unspent: { [new Outpoint( NFTDeposit.hash(), 3 ).hex()]: NFTDeposit.outputs[0].toJSON(), [new Outpoint( leapDeposit.hash(), 0 ).hex()]: leapDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const receiver = Buffer.from( '9999999999999999999999999999999999999999', 'hex' ); const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(leapDeposit.hash(), 0), script, }), new Input({ prevout: new Outpoint(NFTDeposit.hash(), 3), }), ], [ new Output(nftAddr, `0x${receiver.toString('hex')}`, NFT_COLOR_BASE), // gas change returned new Output( 4993380102, leapDeposit.outputs[0].address, leapDeposit.outputs[0].color ), ] ); const tokenId = '0000000000000000000000005555555555555555555555555555555555555555'; const msgData = '0xd01a81e1000000000000000000000000' + // function called `${receiver.toString('hex') + tokenId}`; condition.inputs[0].setMsgData(msgData); await checkSpendCond(state, condition, bridgeState); condition.outputs.push( new Output(4000000, `0x${scriptHash.toString('hex')}`, 0) ); await expectToThrow(checkSpendCond, [state, condition, bridgeState]); condition.outputs.pop(); // remove LEAP input for gas condition.inputs.pop(); await expectToThrow(checkSpendCond, null, [state, condition, bridgeState]); }); test('Spending Condition: return error', async () => { const nftAddr = erc721Tokens[0]; const script = Buffer.from(ErrorCondition, 'hex'); const scriptHash = utils.ripemd160(script); const NFTDeposit = Tx.deposit( 123, // depositId nftAddr, ADDR_1, // owner (spending condition) NFT_COLOR_BASE ); const leapDeposit = Tx.deposit( 1230, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); const state = { unspent: { [new Outpoint( NFTDeposit.hash(), 3 ).hex()]: NFTDeposit.outputs[0].toJSON(), [new Outpoint( leapDeposit.hash(), 0 ).hex()]: leapDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const receiver = Buffer.from( '9999999999999999999999999999999999999999', 'hex' ); const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(leapDeposit.hash(), 0), script, }), new Input({ prevout: new Outpoint(NFTDeposit.hash(), 3), }), ], [ new Output(nftAddr, `0x${receiver.toString('hex')}`, NFT_COLOR_BASE), // gas change returned new Output( 4993380102, leapDeposit.outputs[0].address, leapDeposit.outputs[0].color ), ] ); const tokenId = '0000000000000000000000005555555555555555555555555555555555555555'; const msgData = '0xd01a81e1000000000000000000000000' + // function called `${receiver.toString('hex') + tokenId}`; condition.inputs[0].setMsgData(msgData); await expectToThrow(checkSpendCond, 'error', [ state, condition, bridgeState, ]); }); test('Spending Condition: unused NFT', async () => { const nftAddr = erc721Tokens[0]; const script = Buffer.from( NFTCondition.replace( '1111111111111111111111111111111111111111', nftAddr.replace('0x', '') ), 'hex' ); const scriptHash = utils.ripemd160(script); const NFTDeposit = Tx.deposit( 123, // depositId 456789, // id `0x${scriptHash.toString('hex')}`, // owner (spending condition) NFT_COLOR_BASE ); const NFTDeposit2 = Tx.deposit( 124, // depositId 987654, // id `0x${scriptHash.toString('hex')}`, // owner (spending condition) NFT_COLOR_BASE ); const leapDeposit = Tx.deposit( 1230, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); const state = { unspent: { [new Outpoint( NFTDeposit.hash(), 3 ).hex()]: NFTDeposit.outputs[0].toJSON(), [new Outpoint( NFTDeposit2.hash(), 3 ).hex()]: NFTDeposit2.outputs[0].toJSON(), [new Outpoint( leapDeposit.hash(), 0 ).hex()]: leapDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const receiver = Buffer.from( '9999999999999999999999999999999999999999', 'hex' ); const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(leapDeposit.hash(), 0), script, }), new Input({ prevout: new Outpoint(NFTDeposit.hash(), 3), }), new Input({ prevout: new Outpoint(NFTDeposit2.hash(), 3), }), ], [ new Output(456789, `0x${receiver.toString('hex')}`, NFT_COLOR_BASE), new Output(987654, `0x${receiver.toString('hex')}`, NFT_COLOR_BASE), // gas change returned new Output( 4993380102, leapDeposit.outputs[0].address, leapDeposit.outputs[0].color ), ] ); const tokenId = '000000000000000000000000000000000000000000000000000000000006F855'; const msgData = '0xd01a81e1000000000000000000000000' + // function called `${receiver.toString('hex') + tokenId}`; condition.inputs[0].setMsgData(msgData); await expectToThrow(checkSpendCond, [state, condition, bridgeState]); }); test('Spending Condition: NFT no input for gas', async () => { const nftAddr = erc721Tokens[0]; const script = Buffer.from( NFTCondition.replace( '1111111111111111111111111111111111111111', nftAddr.replace('0x', '') ), 'hex' ); const scriptHash = utils.ripemd160(script); const NFTDeposit = Tx.deposit( 123, // depositId nftAddr, `0x${scriptHash.toString('hex')}`, // owner (spending condition) NFT_COLOR_BASE ); const leapDeposit = Tx.deposit( 1230, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 1 ); const state = { unspent: { [new Outpoint( NFTDeposit.hash(), 3 ).hex()]: NFTDeposit.outputs[0].toJSON(), [new Outpoint( leapDeposit.hash(), 0 ).hex()]: leapDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const receiver = Buffer.from( '9999999999999999999999999999999999999999', 'hex' ); const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(NFTDeposit.hash(), 3), script, }), new Input({ prevout: new Outpoint(leapDeposit.hash(), 0), }), ], [ new Output(nftAddr, `0x${receiver.toString('hex')}`, NFT_COLOR_BASE), new Output( 4995187904, leapDeposit.outputs[0].address, leapDeposit.outputs[0].color ), ] ); const tokenId = '0000000000000000000000005555555555555555555555555555555555555555'; const msgData = '0xd01a81e1000000000000000000000000' + // function called `${receiver.toString('hex') + tokenId}`; condition.inputs[0].setMsgData(msgData); await expectToThrow(checkSpendCond, [state, condition, bridgeState]); }); test('Spending Condition: NST', async () => { const nstAddr = erc1948Tokens[0]; const tokenId = '0x0000000000000000000000005555555555555555555555555555555555555555'; const tokenData = '0x00000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00005'; const script = Buffer.from( NSTCondition.replace( '1111111111111111111111111111111111111111', nstAddr.replace('0x', '') ), 'hex' ); const scriptHash = utils.ripemd160(script); const deposit = Tx.deposit( 123, // depositId tokenId, `0x${scriptHash.toString('hex')}`, // owner (spending condition) NST_COLOR_BASE, '0x0000000000000000000000005555555555555555555555555555555555554444' // tokenData ); // to pay for gas const leapDeposit = Tx.deposit( 1230, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); const state = { unspent: { [new Outpoint(deposit.hash(), 0).hex()]: deposit.outputs[0].toJSON(), [new Outpoint( leapDeposit.hash(), 3 ).hex()]: leapDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(leapDeposit.hash(), 3), script, }), new Input({ prevout: new Outpoint(deposit.hash(), 0), }), ], [ new Output( tokenId, `0x${scriptHash.toString('hex')}`, NST_COLOR_BASE, tokenData ), // gas change returned new Output( 4995187904, leapDeposit.outputs[0].address, leapDeposit.outputs[0].color ), ] ); const msgData = '0xd3b7576c' + // function called `${tokenId.replace('0x', '') + tokenData.replace('0x', '')}`; condition.inputs[0].setMsgData(msgData); await checkSpendCond(state, condition, bridgeState); }); test('Spending Condition: MultiCondition', async () => { const tokenId = '0x0000000000000000000000005555555555555555555555555555555555555555'; const tokenData = '0x00000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00005'; const receiver = '0x82e8C6Cf42C8D1fF9594b17A3F50e94a12cC860f'.toLowerCase(); const script = Buffer.from(MultiCondition, 'hex'); const scriptHash = utils.ripemd160(script); // to pay for gas const leapDeposit = Tx.deposit( 1, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); // to transfer token1 const token1Deposit = Tx.deposit( 2, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 0 ); // to transfer token2 const token2Deposit = Tx.deposit( 3, // depositId 5000000000, `0x${scriptHash.toString('hex')}`, // owner (spending condition) 1 ); const nftDeposit = Tx.deposit( 4, // depositId tokenId, `0x${scriptHash.toString('hex')}`, // owner (spending condition) NFT_COLOR_BASE ); const nstDeposit = Tx.deposit( 5, // depositId tokenId, `0x${scriptHash.toString('hex')}`, // owner (spending condition) NST_COLOR_BASE, '0x0000000000000000000000005555555555555555555555555555555555554444' // tokenData ); const state = { unspent: { [new Outpoint( leapDeposit.hash(), 0 ).hex()]: leapDeposit.outputs[0].toJSON(), [new Outpoint( token1Deposit.hash(), 0 ).hex()]: token1Deposit.outputs[0].toJSON(), [new Outpoint( token2Deposit.hash(), 0 ).hex()]: token2Deposit.outputs[0].toJSON(), [new Outpoint( nftDeposit.hash(), 0 ).hex()]: nftDeposit.outputs[0].toJSON(), [new Outpoint( nstDeposit.hash(), 0 ).hex()]: nstDeposit.outputs[0].toJSON(), }, gas: { minPrice: 0, }, }; // a spending condition transaction that spends the deposit is created const condition = Tx.spendCond( [ new Input({ prevout: new Outpoint(leapDeposit.hash(), 0), script, }), new Input({ prevout: new Outpoint(token1Deposit.hash(), 0), }), new Input({ prevout: new Outpoint(token2Deposit.hash(), 0), }), new Input({ prevout: new Outpoint(nftDeposit.hash(), 0), }), new Input({ prevout: new Outpoint(nstDeposit.hash(), 0), }), ], [ new Output( tokenId, `0x${scriptHash.toString('hex')}`, NST_COLOR_BASE, tokenData ), new Output(tokenId, `0x${receiver.replace('0x', '')}`, NFT_COLOR_BASE), new Output(5000000000, `0x${receiver.replace('0x', '')}`, 0), new Output(5000000000, `0x${receiver.replace('0x', '')}`, 1), new Output(4986820980, `0x${scriptHash.toString('hex')}`, 0), ] ); condition.signAll(PRIV_1); const msgData = '0x5bac6c1e' + // function called `${tokenId.replace('0x', '') + tokenData.replace('0x', '')}000000000000000000000000${receiver.replace( '0x', '' )}`; condition.inputs[0].setMsgData(msgData); await checkSpendCond(state, condition, bridgeState); await checkSpendCond(state, Tx.fromRaw