@bosonprotocol/core-sdk 1.29.0-ludo.1 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/cjs/accounts/handler.d.ts +63 -63
- package/dist/cjs/accounts/handler.js +129 -129
- package/dist/cjs/accounts/index.d.ts +8 -8
- package/dist/cjs/accounts/index.js +37 -37
- package/dist/cjs/accounts/interface.d.ts +38 -38
- package/dist/cjs/accounts/interface.js +130 -130
- package/dist/cjs/accounts/mixin.d.ts +222 -222
- package/dist/cjs/accounts/mixin.js +506 -506
- package/dist/cjs/accounts/subgraph.d.ts +17 -17
- package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
- package/dist/cjs/accounts/subgraph.js +107 -107
- package/dist/cjs/accounts/types.d.ts +28 -28
- package/dist/cjs/accounts/types.d.ts.map +1 -1
- package/dist/cjs/accounts/types.js +8 -8
- package/dist/cjs/core-sdk.d.ts +55 -55
- package/dist/cjs/core-sdk.js +98 -98
- package/dist/cjs/disputes/handler.d.ts +71 -71
- package/dist/cjs/disputes/handler.js +127 -127
- package/dist/cjs/disputes/index.d.ts +3 -3
- package/dist/cjs/disputes/index.js +29 -29
- package/dist/cjs/disputes/interface.d.ts +28 -28
- package/dist/cjs/disputes/interface.js +72 -72
- package/dist/cjs/disputes/mixin.d.ts +117 -117
- package/dist/cjs/disputes/mixin.js +202 -202
- package/dist/cjs/disputes/subgraph.d.ts +5 -5
- package/dist/cjs/disputes/subgraph.d.ts.map +1 -1
- package/dist/cjs/disputes/subgraph.js +29 -29
- package/dist/cjs/erc1155/handler.d.ts +8 -8
- package/dist/cjs/erc1155/handler.js +27 -27
- package/dist/cjs/erc1155/index.d.ts +2 -2
- package/dist/cjs/erc1155/index.js +28 -28
- package/dist/cjs/erc1155/interface.d.ts +2 -2
- package/dist/cjs/erc1155/interface.js +6 -6
- package/dist/cjs/erc1155/mixin.d.ts +5 -5
- package/dist/cjs/erc1155/mixin.js +25 -25
- package/dist/cjs/erc20/handler.d.ts +38 -38
- package/dist/cjs/erc20/handler.js +88 -88
- package/dist/cjs/erc20/index.d.ts +3 -3
- package/dist/cjs/erc20/index.js +29 -29
- package/dist/cjs/erc20/interface.d.ts +2 -2
- package/dist/cjs/erc20/interface.js +6 -6
- package/dist/cjs/erc20/mixin.d.ts +11 -11
- package/dist/cjs/erc20/mixin.js +55 -55
- package/dist/cjs/erc20/subgraph.d.ts +4 -4
- package/dist/cjs/erc20/subgraph.d.ts.map +1 -1
- package/dist/cjs/erc20/subgraph.js +29 -29
- package/dist/cjs/erc721/handler.d.ts +18 -18
- package/dist/cjs/erc721/handler.js +50 -50
- package/dist/cjs/erc721/index.d.ts +2 -2
- package/dist/cjs/erc721/index.js +28 -28
- package/dist/cjs/erc721/interface.d.ts +2 -2
- package/dist/cjs/erc721/interface.js +6 -6
- package/dist/cjs/erc721/mixin.d.ts +7 -7
- package/dist/cjs/erc721/mixin.js +35 -35
- package/dist/cjs/event-logs/index.d.ts +1 -1
- package/dist/cjs/event-logs/index.js +27 -27
- package/dist/cjs/event-logs/mixin.d.ts +10 -10
- package/dist/cjs/event-logs/mixin.js +27 -27
- package/dist/cjs/event-logs/subgraph.d.ts +2 -2
- package/dist/cjs/event-logs/subgraph.js +21 -21
- package/dist/cjs/exchanges/getExchangeState.d.ts +8 -8
- package/dist/cjs/exchanges/getExchangeState.d.ts.map +1 -1
- package/dist/cjs/exchanges/getExchangeState.js +21 -21
- package/dist/cjs/exchanges/getExchangeState.js.map +1 -1
- package/dist/cjs/exchanges/handler.d.ts +30 -30
- package/dist/cjs/exchanges/handler.d.ts.map +1 -1
- package/dist/cjs/exchanges/handler.js +201 -201
- package/dist/cjs/exchanges/index.d.ts +4 -4
- package/dist/cjs/exchanges/index.js +33 -33
- package/dist/cjs/exchanges/interface.d.ts +10 -10
- package/dist/cjs/exchanges/interface.js +49 -49
- package/dist/cjs/exchanges/mixin.d.ts +76 -76
- package/dist/cjs/exchanges/mixin.js +171 -171
- package/dist/cjs/exchanges/subgraph.d.ts +5 -5
- package/dist/cjs/exchanges/subgraph.d.ts.map +1 -1
- package/dist/cjs/exchanges/subgraph.js +29 -29
- package/dist/cjs/forwarder/biconomy-interface.d.ts +71 -71
- package/dist/cjs/forwarder/biconomy-interface.d.ts.map +1 -1
- package/dist/cjs/forwarder/biconomy-interface.js +30 -30
- package/dist/cjs/forwarder/handler.d.ts +18 -18
- package/dist/cjs/forwarder/handler.js +76 -76
- package/dist/cjs/forwarder/index.d.ts +3 -3
- package/dist/cjs/forwarder/index.js +29 -29
- package/dist/cjs/forwarder/mock-interface.d.ts +40 -40
- package/dist/cjs/forwarder/mock-interface.d.ts.map +1 -1
- package/dist/cjs/forwarder/mock-interface.js +15 -15
- package/dist/cjs/funds/handler.d.ts +22 -22
- package/dist/cjs/funds/handler.js +64 -64
- package/dist/cjs/funds/index.d.ts +3 -3
- package/dist/cjs/funds/index.js +29 -29
- package/dist/cjs/funds/interface.d.ts +5 -5
- package/dist/cjs/funds/interface.js +22 -22
- package/dist/cjs/funds/mixin.d.ts +41 -41
- package/dist/cjs/funds/mixin.js +94 -94
- package/dist/cjs/funds/subgraph.d.ts +5 -5
- package/dist/cjs/funds/subgraph.d.ts.map +1 -1
- package/dist/cjs/funds/subgraph.js +29 -29
- package/dist/cjs/groups/handler.d.ts +6 -6
- package/dist/cjs/groups/handler.js +22 -22
- package/dist/cjs/groups/index.d.ts +3 -3
- package/dist/cjs/groups/index.js +29 -29
- package/dist/cjs/groups/interface.d.ts +5 -5
- package/dist/cjs/groups/interface.js +28 -28
- package/dist/cjs/groups/mixin.d.ts +13 -13
- package/dist/cjs/groups/mixin.js +32 -32
- package/dist/cjs/groups/subgraph.d.ts +1 -1
- package/dist/cjs/groups/subgraph.js +4 -4
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +51 -51
- package/dist/cjs/meta-tx/biconomy.d.ts +59 -59
- package/dist/cjs/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/cjs/meta-tx/biconomy.js +107 -107
- package/dist/cjs/meta-tx/handler.d.ts +230 -230
- package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/meta-tx/handler.js +665 -665
- package/dist/cjs/meta-tx/index.d.ts +2 -2
- package/dist/cjs/meta-tx/index.js +28 -28
- package/dist/cjs/meta-tx/interface.d.ts +2 -2
- package/dist/cjs/meta-tx/interface.js +6 -6
- package/dist/cjs/meta-tx/mixin.d.ts +219 -219
- package/dist/cjs/meta-tx/mixin.js +474 -474
- package/dist/cjs/metadata/index.d.ts +1 -1
- package/dist/cjs/metadata/index.js +27 -27
- package/dist/cjs/metadata/mixin.d.ts +41 -41
- package/dist/cjs/metadata/mixin.js +88 -88
- package/dist/cjs/metadata/subgraph.d.ts +20 -20
- package/dist/cjs/metadata/subgraph.d.ts.map +1 -1
- package/dist/cjs/metadata/subgraph.js +108 -108
- package/dist/cjs/mixins/base-core-sdk.d.ts +44 -44
- package/dist/cjs/mixins/base-core-sdk.js +52 -52
- package/dist/cjs/native-meta-tx/handler.d.ts +42 -42
- package/dist/cjs/native-meta-tx/handler.js +135 -135
- package/dist/cjs/native-meta-tx/index.d.ts +2 -2
- package/dist/cjs/native-meta-tx/index.js +28 -28
- package/dist/cjs/native-meta-tx/interface.d.ts +3 -3
- package/dist/cjs/native-meta-tx/interface.js +29 -29
- package/dist/cjs/native-meta-tx/mixin.d.ts +34 -34
- package/dist/cjs/native-meta-tx/mixin.js +67 -67
- package/dist/cjs/native-meta-tx/tokenSpecifics.d.ts +6 -6
- package/dist/cjs/native-meta-tx/tokenSpecifics.d.ts.map +1 -1
- package/dist/cjs/native-meta-tx/tokenSpecifics.js +20 -20
- package/dist/cjs/offers/checkExchangePolicy.d.ts +48 -48
- package/dist/cjs/offers/checkExchangePolicy.d.ts.map +1 -1
- package/dist/cjs/offers/checkExchangePolicy.js +24 -24
- package/dist/cjs/offers/getOfferStatus.d.ts +8 -8
- package/dist/cjs/offers/getOfferStatus.js +25 -25
- package/dist/cjs/offers/getOfferStatus.js.map +1 -1
- package/dist/cjs/offers/handler.d.ts +51 -51
- package/dist/cjs/offers/handler.js +151 -151
- package/dist/cjs/offers/index.d.ts +12 -12
- package/dist/cjs/offers/index.js +41 -41
- package/dist/cjs/offers/interface.d.ts +18 -18
- package/dist/cjs/offers/interface.js +91 -91
- package/dist/cjs/offers/mixin.d.ts +170 -170
- package/dist/cjs/offers/mixin.js +408 -408
- package/dist/cjs/offers/renderContractualAgreement.d.ts +53 -53
- package/dist/cjs/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/cjs/offers/renderContractualAgreement.js +232 -232
- package/dist/cjs/offers/storage.d.ts +12 -12
- package/dist/cjs/offers/storage.js +29 -29
- package/dist/cjs/offers/subgraph.d.ts +5 -5
- package/dist/cjs/offers/subgraph.d.ts.map +1 -1
- package/dist/cjs/offers/subgraph.js +29 -29
- package/dist/cjs/offers/types.d.ts +1 -1
- package/dist/cjs/offers/types.js +2 -2
- package/dist/cjs/orchestration/handler.d.ts +73 -73
- package/dist/cjs/orchestration/handler.js +146 -146
- package/dist/cjs/orchestration/index.d.ts +2 -2
- package/dist/cjs/orchestration/index.js +28 -28
- package/dist/cjs/orchestration/interface.d.ts +14 -14
- package/dist/cjs/orchestration/interface.js +114 -114
- package/dist/cjs/orchestration/mixin.d.ts +84 -84
- package/dist/cjs/orchestration/mixin.js +163 -163
- package/dist/cjs/seaport/abi.d.ts +40 -40
- package/dist/cjs/seaport/abi.js +152 -152
- package/dist/cjs/seaport/handler.d.ts +45 -45
- package/dist/cjs/seaport/handler.d.ts.map +1 -1
- package/dist/cjs/seaport/handler.js +27 -27
- package/dist/cjs/seaport/handler.js.map +1 -1
- package/dist/cjs/seaport/index.d.ts +1 -1
- package/dist/cjs/seaport/index.js +27 -27
- package/dist/cjs/subgraph.d.ts +33033 -33033
- package/dist/cjs/subgraph.d.ts.map +1 -1
- package/dist/cjs/subgraph.js +854 -854
- package/dist/cjs/subgraph.js.map +1 -1
- package/dist/cjs/utils/errors.d.ts +4 -4
- package/dist/cjs/utils/errors.js +10 -10
- package/dist/cjs/utils/graphql.d.ts +315 -315
- package/dist/cjs/utils/graphql.js +10 -10
- package/dist/cjs/utils/logs.d.ts +20 -20
- package/dist/cjs/utils/logs.js +53 -53
- package/dist/cjs/utils/signature.d.ts +23 -23
- package/dist/cjs/utils/signature.d.ts.map +1 -1
- package/dist/cjs/utils/signature.js +64 -64
- package/dist/cjs/utils/tokenInfoManager.d.ts +23 -23
- package/dist/cjs/utils/tokenInfoManager.js +139 -139
- package/dist/cjs/voucher/handler.d.ts +68 -68
- package/dist/cjs/voucher/handler.js +134 -134
- package/dist/cjs/voucher/index.d.ts +2 -2
- package/dist/cjs/voucher/index.js +28 -28
- package/dist/cjs/voucher/interface.d.ts +21 -21
- package/dist/cjs/voucher/interface.js +140 -140
- package/dist/cjs/voucher/mixin.d.ts +67 -67
- package/dist/cjs/voucher/mixin.js +166 -166
- package/dist/esm/accounts/handler.d.ts +63 -63
- package/dist/esm/accounts/handler.js +91 -91
- package/dist/esm/accounts/index.d.ts +8 -8
- package/dist/esm/accounts/index.js +8 -8
- package/dist/esm/accounts/interface.d.ts +38 -38
- package/dist/esm/accounts/interface.js +111 -111
- package/dist/esm/accounts/mixin.d.ts +222 -222
- package/dist/esm/accounts/mixin.js +416 -416
- package/dist/esm/accounts/subgraph.d.ts +17 -17
- package/dist/esm/accounts/subgraph.d.ts.map +1 -1
- package/dist/esm/accounts/subgraph.js +99 -99
- package/dist/esm/accounts/types.d.ts +28 -28
- package/dist/esm/accounts/types.d.ts.map +1 -1
- package/dist/esm/accounts/types.js +1 -1
- package/dist/esm/core-sdk.d.ts +55 -55
- package/dist/esm/core-sdk.js +97 -97
- package/dist/esm/disputes/handler.d.ts +71 -71
- package/dist/esm/disputes/handler.js +82 -82
- package/dist/esm/disputes/index.d.ts +3 -3
- package/dist/esm/disputes/index.js +3 -3
- package/dist/esm/disputes/interface.d.ts +28 -28
- package/dist/esm/disputes/interface.js +59 -59
- package/dist/esm/disputes/mixin.d.ts +117 -117
- package/dist/esm/disputes/mixin.js +172 -172
- package/dist/esm/disputes/subgraph.d.ts +5 -5
- package/dist/esm/disputes/subgraph.d.ts.map +1 -1
- package/dist/esm/disputes/subgraph.js +14 -14
- package/dist/esm/erc1155/handler.d.ts +8 -8
- package/dist/esm/erc1155/handler.js +12 -12
- package/dist/esm/erc1155/index.d.ts +2 -2
- package/dist/esm/erc1155/index.js +2 -2
- package/dist/esm/erc1155/interface.d.ts +2 -2
- package/dist/esm/erc1155/interface.js +3 -3
- package/dist/esm/erc1155/mixin.d.ts +5 -5
- package/dist/esm/erc1155/mixin.js +10 -10
- package/dist/esm/erc20/handler.d.ts +38 -38
- package/dist/esm/erc20/handler.js +55 -55
- package/dist/esm/erc20/index.d.ts +3 -3
- package/dist/esm/erc20/index.js +3 -3
- package/dist/esm/erc20/interface.d.ts +2 -2
- package/dist/esm/erc20/interface.js +3 -3
- package/dist/esm/erc20/mixin.d.ts +11 -11
- package/dist/esm/erc20/mixin.js +28 -28
- package/dist/esm/erc20/subgraph.d.ts +4 -4
- package/dist/esm/erc20/subgraph.d.ts.map +1 -1
- package/dist/esm/erc20/subgraph.js +14 -14
- package/dist/esm/erc721/handler.d.ts +18 -18
- package/dist/esm/erc721/handler.js +29 -29
- package/dist/esm/erc721/index.d.ts +2 -2
- package/dist/esm/erc721/index.js +2 -2
- package/dist/esm/erc721/interface.d.ts +2 -2
- package/dist/esm/erc721/interface.js +3 -3
- package/dist/esm/erc721/mixin.d.ts +7 -7
- package/dist/esm/erc721/mixin.js +16 -16
- package/dist/esm/event-logs/index.d.ts +1 -1
- package/dist/esm/event-logs/index.js +1 -1
- package/dist/esm/event-logs/mixin.d.ts +10 -10
- package/dist/esm/event-logs/mixin.js +12 -12
- package/dist/esm/event-logs/subgraph.d.ts +2 -2
- package/dist/esm/event-logs/subgraph.js +6 -6
- package/dist/esm/exchanges/getExchangeState.d.ts +8 -8
- package/dist/esm/exchanges/getExchangeState.d.ts.map +1 -1
- package/dist/esm/exchanges/getExchangeState.js +17 -17
- package/dist/esm/exchanges/handler.d.ts +30 -30
- package/dist/esm/exchanges/handler.d.ts.map +1 -1
- package/dist/esm/exchanges/handler.js +168 -168
- package/dist/esm/exchanges/index.d.ts +4 -4
- package/dist/esm/exchanges/index.js +4 -4
- package/dist/esm/exchanges/interface.d.ts +10 -10
- package/dist/esm/exchanges/interface.js +39 -39
- package/dist/esm/exchanges/mixin.d.ts +76 -76
- package/dist/esm/exchanges/mixin.js +140 -140
- package/dist/esm/exchanges/subgraph.d.ts +5 -5
- package/dist/esm/exchanges/subgraph.d.ts.map +1 -1
- package/dist/esm/exchanges/subgraph.js +14 -14
- package/dist/esm/forwarder/biconomy-interface.d.ts +71 -71
- package/dist/esm/forwarder/biconomy-interface.d.ts.map +1 -1
- package/dist/esm/forwarder/biconomy-interface.js +23 -23
- package/dist/esm/forwarder/handler.d.ts +18 -18
- package/dist/esm/forwarder/handler.js +35 -35
- package/dist/esm/forwarder/index.d.ts +3 -3
- package/dist/esm/forwarder/index.js +3 -3
- package/dist/esm/forwarder/mock-interface.d.ts +40 -40
- package/dist/esm/forwarder/mock-interface.d.ts.map +1 -1
- package/dist/esm/forwarder/mock-interface.js +10 -10
- package/dist/esm/funds/handler.d.ts +22 -22
- package/dist/esm/funds/handler.js +43 -43
- package/dist/esm/funds/index.d.ts +3 -3
- package/dist/esm/funds/index.js +3 -3
- package/dist/esm/funds/interface.d.ts +5 -5
- package/dist/esm/funds/interface.js +17 -17
- package/dist/esm/funds/mixin.d.ts +41 -41
- package/dist/esm/funds/mixin.js +71 -71
- package/dist/esm/funds/subgraph.d.ts +5 -5
- package/dist/esm/funds/subgraph.d.ts.map +1 -1
- package/dist/esm/funds/subgraph.js +14 -14
- package/dist/esm/groups/handler.d.ts +6 -6
- package/dist/esm/groups/handler.js +7 -7
- package/dist/esm/groups/index.d.ts +3 -3
- package/dist/esm/groups/index.js +3 -3
- package/dist/esm/groups/interface.d.ts +5 -5
- package/dist/esm/groups/interface.js +23 -23
- package/dist/esm/groups/mixin.d.ts +13 -13
- package/dist/esm/groups/mixin.js +17 -17
- package/dist/esm/groups/subgraph.d.ts +1 -1
- package/dist/esm/groups/subgraph.js +1 -1
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +17 -17
- package/dist/esm/meta-tx/biconomy.d.ts +59 -59
- package/dist/esm/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/esm/meta-tx/biconomy.js +89 -89
- package/dist/esm/meta-tx/handler.d.ts +230 -230
- package/dist/esm/meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/meta-tx/handler.js +733 -733
- package/dist/esm/meta-tx/index.d.ts +2 -2
- package/dist/esm/meta-tx/index.js +2 -2
- package/dist/esm/meta-tx/interface.d.ts +2 -2
- package/dist/esm/meta-tx/interface.js +3 -3
- package/dist/esm/meta-tx/mixin.d.ts +219 -219
- package/dist/esm/meta-tx/mixin.js +568 -568
- package/dist/esm/metadata/index.d.ts +1 -1
- package/dist/esm/metadata/index.js +1 -1
- package/dist/esm/metadata/mixin.d.ts +41 -41
- package/dist/esm/metadata/mixin.js +59 -59
- package/dist/esm/metadata/subgraph.d.ts +20 -20
- package/dist/esm/metadata/subgraph.d.ts.map +1 -1
- package/dist/esm/metadata/subgraph.js +86 -86
- package/dist/esm/mixins/base-core-sdk.d.ts +44 -44
- package/dist/esm/mixins/base-core-sdk.js +57 -57
- package/dist/esm/native-meta-tx/handler.d.ts +42 -42
- package/dist/esm/native-meta-tx/handler.js +121 -121
- package/dist/esm/native-meta-tx/index.d.ts +2 -2
- package/dist/esm/native-meta-tx/index.js +2 -2
- package/dist/esm/native-meta-tx/interface.d.ts +3 -3
- package/dist/esm/native-meta-tx/interface.js +26 -26
- package/dist/esm/native-meta-tx/mixin.d.ts +34 -34
- package/dist/esm/native-meta-tx/mixin.js +50 -50
- package/dist/esm/native-meta-tx/tokenSpecifics.d.ts +6 -6
- package/dist/esm/native-meta-tx/tokenSpecifics.d.ts.map +1 -1
- package/dist/esm/native-meta-tx/tokenSpecifics.js +15 -15
- package/dist/esm/offers/checkExchangePolicy.d.ts +48 -48
- package/dist/esm/offers/checkExchangePolicy.d.ts.map +1 -1
- package/dist/esm/offers/checkExchangePolicy.js +19 -19
- package/dist/esm/offers/getOfferStatus.d.ts +8 -8
- package/dist/esm/offers/getOfferStatus.js +21 -21
- package/dist/esm/offers/handler.d.ts +51 -51
- package/dist/esm/offers/handler.js +118 -118
- package/dist/esm/offers/index.d.ts +12 -12
- package/dist/esm/offers/index.js +12 -12
- package/dist/esm/offers/interface.d.ts +18 -18
- package/dist/esm/offers/interface.js +75 -75
- package/dist/esm/offers/mixin.d.ts +170 -170
- package/dist/esm/offers/mixin.js +338 -338
- package/dist/esm/offers/renderContractualAgreement.d.ts +53 -53
- package/dist/esm/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/esm/offers/renderContractualAgreement.js +208 -208
- package/dist/esm/offers/storage.d.ts +12 -12
- package/dist/esm/offers/storage.js +14 -14
- package/dist/esm/offers/subgraph.d.ts +5 -5
- package/dist/esm/offers/subgraph.d.ts.map +1 -1
- package/dist/esm/offers/subgraph.js +16 -16
- package/dist/esm/offers/types.d.ts +1 -1
- package/dist/esm/offers/types.js +1 -1
- package/dist/esm/orchestration/handler.d.ts +73 -73
- package/dist/esm/orchestration/handler.js +110 -110
- package/dist/esm/orchestration/index.d.ts +2 -2
- package/dist/esm/orchestration/index.js +2 -2
- package/dist/esm/orchestration/interface.d.ts +14 -14
- package/dist/esm/orchestration/interface.js +103 -103
- package/dist/esm/orchestration/mixin.d.ts +84 -84
- package/dist/esm/orchestration/mixin.js +136 -136
- package/dist/esm/seaport/abi.d.ts +40 -40
- package/dist/esm/seaport/abi.js +149 -149
- package/dist/esm/seaport/handler.d.ts +45 -45
- package/dist/esm/seaport/handler.d.ts.map +1 -1
- package/dist/esm/seaport/handler.js +23 -23
- package/dist/esm/seaport/index.d.ts +1 -1
- package/dist/esm/seaport/index.js +1 -1
- package/dist/esm/subgraph.d.ts +33033 -33033
- package/dist/esm/subgraph.d.ts.map +1 -1
- package/dist/esm/subgraph.js +854 -854
- package/dist/esm/utils/errors.d.ts +4 -4
- package/dist/esm/utils/errors.js +7 -7
- package/dist/esm/utils/graphql.d.ts +315 -315
- package/dist/esm/utils/graphql.js +6 -6
- package/dist/esm/utils/logs.d.ts +20 -20
- package/dist/esm/utils/logs.js +47 -47
- package/dist/esm/utils/signature.d.ts +23 -23
- package/dist/esm/utils/signature.d.ts.map +1 -1
- package/dist/esm/utils/signature.js +57 -57
- package/dist/esm/utils/tokenInfoManager.d.ts +23 -23
- package/dist/esm/utils/tokenInfoManager.js +125 -125
- package/dist/esm/voucher/handler.d.ts +68 -68
- package/dist/esm/voucher/handler.js +86 -86
- package/dist/esm/voucher/index.d.ts +2 -2
- package/dist/esm/voucher/index.js +2 -2
- package/dist/esm/voucher/interface.d.ts +21 -21
- package/dist/esm/voucher/interface.js +119 -119
- package/dist/esm/voucher/mixin.d.ts +67 -67
- package/dist/esm/voucher/mixin.js +135 -135
- package/package.json +10 -6
|
@@ -1,666 +1,666 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getResubmitted = exports.relayMetaTransaction = exports.signMetaTxDepositFunds = exports.signMetaTxWithdrawFunds = exports.signMetaTxExtendDisputeTimeout = exports.signMetaTxResolveDispute = exports.signMetaTxRaiseDispute = exports.signMetaTxEscalateDispute = exports.signMetaTxRetractDispute = exports.signMetaTxCompleteExchange = exports.signMetaTxRedeemVoucher = exports.signMetaTxCancelVoucher = exports.signMetaTxCommitToOffer = exports.signMetaTxCreateOfferWithCondition = exports.signMetaTxCallExternalContract = exports.signMetaTxSetApprovalForAllToContract = exports.signMetaTxSetApprovalForAll = exports.signMetaTxPreMint = exports.signMetaTxReserveRange = exports.signMetaTxCreateGroup = exports.signMetaTxRevokeVoucher = exports.signMetaTxExpireVoucher = exports.signMetaTxCompleteExchangeBatch = exports.signMetaTxExtendOfferBatch = exports.signMetaTxExtendOffer = exports.signMetaTxVoidOfferBatch = exports.signMetaTxVoidOffer = exports.signMetaTxCreateOfferBatch = exports.signMetaTxCreateOffer = exports.signMetaTxOptInToSellerUpdate = exports.signMetaTxUpdateSeller = exports.signMetaTxCreateSeller = exports.relayBiconomyMetaTransaction = exports.signBiconomyVoucherMetaTx = exports.signVoucherMetaTx = exports.signMetaTx = void 0;
|
|
13
|
-
const common_1 = require("@bosonprotocol/common");
|
|
14
|
-
const storage_1 = require("../offers/storage");
|
|
15
|
-
const bignumber_1 = require("@ethersproject/bignumber");
|
|
16
|
-
const interface_1 = require("../accounts/interface");
|
|
17
|
-
const interface_2 = require("../exchanges/interface");
|
|
18
|
-
const interface_3 = require("../offers/interface");
|
|
19
|
-
const signature_1 = require("../utils/signature");
|
|
20
|
-
const biconomy_1 = require("./biconomy");
|
|
21
|
-
const address_1 = require("@ethersproject/address");
|
|
22
|
-
const constants_1 = require("@ethersproject/constants");
|
|
23
|
-
const interface_4 = require("../funds/interface");
|
|
24
|
-
const interface_5 = require("../disputes/interface");
|
|
25
|
-
const interface_6 = require("../groups/interface");
|
|
26
|
-
const interface_7 = require("../orchestration/interface");
|
|
27
|
-
const interface_8 = require("../voucher/interface");
|
|
28
|
-
const keccak256_1 = require("@ethersproject/keccak256");
|
|
29
|
-
const hash_1 = require("@ethersproject/hash");
|
|
30
|
-
const abi_1 = require("@ethersproject/abi");
|
|
31
|
-
const handler_1 = require("../forwarder/handler");
|
|
32
|
-
const handler_2 = require("../voucher/handler");
|
|
33
|
-
function signMetaTx(args) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const metaTransactionType = [
|
|
36
|
-
{ name: "nonce", type: "uint256" },
|
|
37
|
-
{ name: "from", type: "address" },
|
|
38
|
-
{ name: "contractAddress", type: "address" },
|
|
39
|
-
{ name: "functionName", type: "string" },
|
|
40
|
-
{ name: "functionSignature", type: "bytes" }
|
|
41
|
-
];
|
|
42
|
-
const customSignatureType = {
|
|
43
|
-
MetaTransaction: metaTransactionType
|
|
44
|
-
};
|
|
45
|
-
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
46
|
-
const message = {
|
|
47
|
-
nonce: args.nonce,
|
|
48
|
-
from: signerAddress,
|
|
49
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
50
|
-
functionName: args.functionName,
|
|
51
|
-
functionSignature: args.functionSignature
|
|
52
|
-
};
|
|
53
|
-
const signature = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTransaction", message }));
|
|
54
|
-
return Object.assign({ functionName: args.functionName, functionSignature: args.functionSignature }, signature);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
exports.signMetaTx = signMetaTx;
|
|
58
|
-
function signVoucherMetaTx(args) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const forwardType = [
|
|
61
|
-
{ name: "from", type: "address" },
|
|
62
|
-
{ name: "to", type: "address" },
|
|
63
|
-
{ name: "nonce", type: "uint256" },
|
|
64
|
-
{ name: "data", type: "bytes" }
|
|
65
|
-
];
|
|
66
|
-
const customSignatureType = {
|
|
67
|
-
EIP712Domain: [
|
|
68
|
-
{ name: "name", type: "string" },
|
|
69
|
-
{ name: "version", type: "string" },
|
|
70
|
-
{ name: "chainId", type: "uint256" },
|
|
71
|
-
{ name: "verifyingContract", type: "address" }
|
|
72
|
-
],
|
|
73
|
-
ForwardRequest: forwardType
|
|
74
|
-
};
|
|
75
|
-
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
76
|
-
const chainId = yield args.web3Lib.getChainId();
|
|
77
|
-
const nonce = yield (0, handler_1.getNonce)({
|
|
78
|
-
contractAddress: args.forwarderAddress,
|
|
79
|
-
user: signerAddress,
|
|
80
|
-
web3Lib: args.web3Lib,
|
|
81
|
-
forwarderAbi: args.forwarderAbi
|
|
82
|
-
});
|
|
83
|
-
const message = {
|
|
84
|
-
from: signerAddress,
|
|
85
|
-
to: args.bosonVoucherAddress,
|
|
86
|
-
nonce,
|
|
87
|
-
data: args.functionSignature
|
|
88
|
-
};
|
|
89
|
-
const signature = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.forwarderAddress, customSignatureType, primaryType: "ForwardRequest", message, customDomainData: {
|
|
90
|
-
name: "MockForwarder",
|
|
91
|
-
version: "0.0.1",
|
|
92
|
-
chainId,
|
|
93
|
-
salt: undefined
|
|
94
|
-
} }));
|
|
95
|
-
return Object.assign({ to: message.to, functionSignature: args.functionSignature, request: message }, signature);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
exports.signVoucherMetaTx = signVoucherMetaTx;
|
|
99
|
-
function signBiconomyVoucherMetaTx(args) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const customSignatureType = {
|
|
102
|
-
EIP712Domain: [
|
|
103
|
-
{ name: "name", type: "string" },
|
|
104
|
-
{ name: "version", type: "string" },
|
|
105
|
-
// { name: "chainId", type: "uint256" },
|
|
106
|
-
// { name: "verifyingContract", type: "address" }
|
|
107
|
-
{ name: "verifyingContract", type: "address" },
|
|
108
|
-
{ name: "salt", type: "bytes32" }
|
|
109
|
-
],
|
|
110
|
-
ERC20ForwardRequest: [
|
|
111
|
-
{ name: "from", type: "address" },
|
|
112
|
-
{ name: "to", type: "address" },
|
|
113
|
-
{ name: "token", type: "address" },
|
|
114
|
-
{ name: "txGas", type: "uint256" },
|
|
115
|
-
{ name: "tokenGasPrice", type: "uint256" },
|
|
116
|
-
{ name: "batchId", type: "uint256" },
|
|
117
|
-
{ name: "batchNonce", type: "uint256" },
|
|
118
|
-
{ name: "deadline", type: "uint256" },
|
|
119
|
-
{ name: "data", type: "bytes" }
|
|
120
|
-
]
|
|
121
|
-
};
|
|
122
|
-
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
123
|
-
const chainId = yield args.web3Lib.getChainId();
|
|
124
|
-
// Check which forwarder needs to be used for the contract
|
|
125
|
-
const biconomyForwarderDomainDetails = yield new biconomy_1.Biconomy(args.relayerUrl).getForwarderDomainDetails({ chainId });
|
|
126
|
-
const biconomyForwarderDomainData = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
try {
|
|
128
|
-
for (const bFDD of Object.values(biconomyForwarderDomainDetails)) {
|
|
129
|
-
const ret = yield (0, handler_2.isTrustedForwarder)({
|
|
130
|
-
forwarder: bFDD.verifyingContract,
|
|
131
|
-
contractAddress: args.bosonVoucherAddress,
|
|
132
|
-
web3Lib: args.web3Lib
|
|
133
|
-
});
|
|
134
|
-
if (ret) {
|
|
135
|
-
resolve(bFDD);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
resolve(undefined);
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
reject(e);
|
|
142
|
-
}
|
|
143
|
-
}));
|
|
144
|
-
if (!biconomyForwarderDomainData) {
|
|
145
|
-
throw `Unable to find the trusted forwarder for BosonVoucher contract ${args.bosonVoucherAddress}`;
|
|
146
|
-
}
|
|
147
|
-
const nonce = yield (0, handler_1.getNonce)({
|
|
148
|
-
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
149
|
-
user: signerAddress,
|
|
150
|
-
web3Lib: args.web3Lib,
|
|
151
|
-
batchId: args.batchId,
|
|
152
|
-
forwarderAbi: args.forwarderAbi
|
|
153
|
-
});
|
|
154
|
-
const message = {
|
|
155
|
-
from: signerAddress,
|
|
156
|
-
to: args.bosonVoucherAddress,
|
|
157
|
-
token: "0x0000000000000000000000000000000000000000",
|
|
158
|
-
txGas: args.txGas,
|
|
159
|
-
tokenGasPrice: "0",
|
|
160
|
-
batchId: args.batchId,
|
|
161
|
-
batchNonce: nonce,
|
|
162
|
-
deadline: Math.floor(Date.now() / 1000 + 3600),
|
|
163
|
-
data: args.functionSignature
|
|
164
|
-
};
|
|
165
|
-
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { chainId, verifyingContractAddress: biconomyForwarderDomainData.verifyingContract, customSignatureType, primaryType: "ERC20ForwardRequest", message, customDomainData: Object.assign({}, biconomyForwarderDomainData
|
|
166
|
-
// chainId
|
|
167
|
-
// salt: undefined
|
|
168
|
-
) }));
|
|
169
|
-
const signature = signatureParams.signature;
|
|
170
|
-
const getDomainSeparator = () => __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const domainData = biconomyForwarderDomainData;
|
|
172
|
-
const domainSeparator = (0, keccak256_1.keccak256)(abi_1.defaultAbiCoder.encode(["bytes32", "bytes32", "bytes32", "address", "bytes32"], [
|
|
173
|
-
(0, hash_1.id)("EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"),
|
|
174
|
-
(0, hash_1.id)(domainData.name),
|
|
175
|
-
(0, hash_1.id)(domainData.version),
|
|
176
|
-
domainData.verifyingContract,
|
|
177
|
-
domainData.salt
|
|
178
|
-
]));
|
|
179
|
-
return domainSeparator;
|
|
180
|
-
});
|
|
181
|
-
const domainSeparator = yield getDomainSeparator();
|
|
182
|
-
// verify signature
|
|
183
|
-
const signatureVerified = yield (0, handler_1.verifyEIP712)({
|
|
184
|
-
request: message,
|
|
185
|
-
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
186
|
-
web3Lib: args.web3Lib,
|
|
187
|
-
domainSeparator,
|
|
188
|
-
forwarderAbi: args.forwarderAbi,
|
|
189
|
-
signature
|
|
190
|
-
});
|
|
191
|
-
if (!signatureVerified) {
|
|
192
|
-
throw `Signature is not verified`;
|
|
193
|
-
}
|
|
194
|
-
return Object.assign(Object.assign({ to: message.to, domainSeparator, request: message }, signatureParams), { signature, functionSignature: args.functionSignature });
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
exports.signBiconomyVoucherMetaTx = signBiconomyVoucherMetaTx;
|
|
198
|
-
function relayBiconomyMetaTransaction(args) {
|
|
199
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const { chainId, contractAddress, metaTx } = args;
|
|
201
|
-
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
202
|
-
const relayTxResponse = yield biconomy.relayTransaction({
|
|
203
|
-
to: contractAddress,
|
|
204
|
-
params: [
|
|
205
|
-
metaTx.params.request,
|
|
206
|
-
metaTx.params.domainSeparator,
|
|
207
|
-
metaTx.params.signature
|
|
208
|
-
],
|
|
209
|
-
from: metaTx.params.userAddress,
|
|
210
|
-
signatureType: "EIP712_SIGN"
|
|
211
|
-
});
|
|
212
|
-
return {
|
|
213
|
-
wait: () => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
const waitResponse = yield biconomy.wait({
|
|
215
|
-
networkId: chainId,
|
|
216
|
-
transactionHash: relayTxResponse.txHash
|
|
217
|
-
});
|
|
218
|
-
const txHash = waitResponse.data.newHash;
|
|
219
|
-
const txReceipt = yield args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
220
|
-
return {
|
|
221
|
-
to: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.to) || contractAddress,
|
|
222
|
-
from: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.from) || metaTx.params.userAddress,
|
|
223
|
-
transactionHash: txHash,
|
|
224
|
-
logs: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.logs) || [],
|
|
225
|
-
effectiveGasPrice: bignumber_1.BigNumber.from(waitResponse.data.newGasPrice)
|
|
226
|
-
};
|
|
227
|
-
}),
|
|
228
|
-
hash: relayTxResponse.txHash
|
|
229
|
-
};
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
exports.relayBiconomyMetaTransaction = relayBiconomyMetaTransaction;
|
|
233
|
-
function signMetaTxCreateSeller(args) {
|
|
234
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
236
|
-
metadataUriOrHash: args.createSellerArgs.metadataUri,
|
|
237
|
-
metadataStorage: args.metadataStorage,
|
|
238
|
-
theGraphStorage: args.theGraphStorage
|
|
239
|
-
});
|
|
240
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256))", functionSignature: (0, interface_1.encodeCreateSeller)(args.createSellerArgs) }));
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
exports.signMetaTxCreateSeller = signMetaTxCreateSeller;
|
|
244
|
-
function signMetaTxUpdateSeller(args) {
|
|
245
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
247
|
-
metadataUriOrHash: args.updateSellerArgs.metadataUri,
|
|
248
|
-
metadataStorage: args.metadataStorage,
|
|
249
|
-
theGraphStorage: args.theGraphStorage
|
|
250
|
-
});
|
|
251
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "updateSeller((uint256,address,address,address,address,bool,string),(uint256,uint8))", functionSignature: (0, interface_1.encodeUpdateSeller)(args.updateSellerArgs) }));
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
exports.signMetaTxUpdateSeller = signMetaTxUpdateSeller;
|
|
255
|
-
function signMetaTxOptInToSellerUpdate(args) {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "optInToSellerUpdate(uint256,uint8[])", functionSignature: (0, interface_1.encodeOptInToSellerUpdate)(args.optInToSellerUpdateArgs) }));
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
exports.signMetaTxOptInToSellerUpdate = signMetaTxOptInToSellerUpdate;
|
|
261
|
-
function signMetaTxCreateOffer(args) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
common_1.utils.validation.createOfferArgsSchema.validateSync(args.createOfferArgs, {
|
|
264
|
-
abortEarly: false
|
|
265
|
-
});
|
|
266
|
-
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
267
|
-
metadataUriOrHash: args.createOfferArgs.metadataUri,
|
|
268
|
-
metadataStorage: args.metadataStorage,
|
|
269
|
-
theGraphStorage: args.theGraphStorage
|
|
270
|
-
});
|
|
271
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)", functionSignature: (0, interface_3.encodeCreateOffer)(args.createOfferArgs) }));
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
exports.signMetaTxCreateOffer = signMetaTxCreateOffer;
|
|
275
|
-
function signMetaTxCreateOfferBatch(args) {
|
|
276
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
for (const offerToCreate of args.createOffersArgs) {
|
|
278
|
-
common_1.utils.validation.createOfferArgsSchema.validateSync(offerToCreate, {
|
|
279
|
-
abortEarly: false
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
yield Promise.all(args.createOffersArgs.map((offerToCreate) => (0, storage_1.storeMetadataOnTheGraph)({
|
|
283
|
-
metadataUriOrHash: offerToCreate.metadataUri,
|
|
284
|
-
metadataStorage: args.metadataStorage,
|
|
285
|
-
theGraphStorage: args.theGraphStorage
|
|
286
|
-
})));
|
|
287
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])", functionSignature: (0, interface_3.encodeCreateOfferBatch)(args.createOffersArgs) }));
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
exports.signMetaTxCreateOfferBatch = signMetaTxCreateOfferBatch;
|
|
291
|
-
function signMetaTxVoidOffer(args) {
|
|
292
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "voidOffer(uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("voidOffer", [
|
|
294
|
-
args.offerId
|
|
295
|
-
]) }));
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
exports.signMetaTxVoidOffer = signMetaTxVoidOffer;
|
|
299
|
-
function signMetaTxVoidOfferBatch(args) {
|
|
300
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "voidOfferBatch(uint256[])", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("voidOfferBatch", [args.offerIds]) }));
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
exports.signMetaTxVoidOfferBatch = signMetaTxVoidOfferBatch;
|
|
305
|
-
function signMetaTxExtendOffer(args) {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendOffer(uint256,uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("extendOffer", [args.offerId, args.validUntil]) }));
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
exports.signMetaTxExtendOffer = signMetaTxExtendOffer;
|
|
311
|
-
function signMetaTxExtendOfferBatch(args) {
|
|
312
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendOfferBatch(uint256[],uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("extendOfferBatch", [args.offerIds, args.validUntil]) }));
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
exports.signMetaTxExtendOfferBatch = signMetaTxExtendOfferBatch;
|
|
317
|
-
function signMetaTxCompleteExchangeBatch(args) {
|
|
318
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
319
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "completeExchangeBatch(uint256[])", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("completeExchangeBatch", [args.exchangeIds]) }));
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
exports.signMetaTxCompleteExchangeBatch = signMetaTxCompleteExchangeBatch;
|
|
323
|
-
function signMetaTxExpireVoucher(args) {
|
|
324
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "expireVoucher(uint256)", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("expireVoucher", [args.exchangeId]) }));
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
exports.signMetaTxExpireVoucher = signMetaTxExpireVoucher;
|
|
329
|
-
function signMetaTxRevokeVoucher(args) {
|
|
330
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "revokeVoucher(uint256)", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("revokeVoucher", [args.exchangeId]) }));
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
exports.signMetaTxRevokeVoucher = signMetaTxRevokeVoucher;
|
|
335
|
-
function signMetaTxCreateGroup(args) {
|
|
336
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))", functionSignature: (0, interface_6.encodeCreateGroup)(args.createGroupArgs) }));
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
exports.signMetaTxCreateGroup = signMetaTxCreateGroup;
|
|
341
|
-
function signMetaTxReserveRange(args) {
|
|
342
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "reserveRange(uint256,uint256,address)", functionSignature: (0, interface_3.encodeReserveRange)(args.offerId, args.length, args.to) }));
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
exports.signMetaTxReserveRange = signMetaTxReserveRange;
|
|
347
|
-
function signMetaTxPreMint(args) {
|
|
348
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
-
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
350
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
351
|
-
const functionSignature = (0, interface_8.encodePreMint)(args.offerId, args.amount);
|
|
352
|
-
if (isLocal) {
|
|
353
|
-
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
354
|
-
}
|
|
355
|
-
const txGas = 200000 + bignumber_1.BigNumber.from(args.amount).mul(2500).toNumber(); // ~(180000 + 2250*N) estimation on 2023/02/03
|
|
356
|
-
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
exports.signMetaTxPreMint = signMetaTxPreMint;
|
|
360
|
-
function signMetaTxSetApprovalForAll(args) {
|
|
361
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
-
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
363
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
364
|
-
const functionSignature = (0, interface_8.encodeSetApprovalForAll)(args.operator, args.approved);
|
|
365
|
-
if (isLocal) {
|
|
366
|
-
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
367
|
-
}
|
|
368
|
-
const txGas = 100000; // ~70000 estimation on 2023/02/03
|
|
369
|
-
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
exports.signMetaTxSetApprovalForAll = signMetaTxSetApprovalForAll;
|
|
373
|
-
function signMetaTxSetApprovalForAllToContract(args, overrides = {}) {
|
|
374
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
-
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
376
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
377
|
-
const functionSignature = (0, interface_8.encodeSetApprovalForAllToContract)(args.operator, args.approved);
|
|
378
|
-
if (isLocal) {
|
|
379
|
-
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
380
|
-
}
|
|
381
|
-
const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
|
|
382
|
-
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
exports.signMetaTxSetApprovalForAllToContract = signMetaTxSetApprovalForAllToContract;
|
|
386
|
-
function signMetaTxCallExternalContract(args, overrides = {}) {
|
|
387
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
388
|
-
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
389
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
390
|
-
const functionSignature = (0, interface_8.encodeCallExternalContract)(args.to, args.data);
|
|
391
|
-
if (isLocal) {
|
|
392
|
-
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
393
|
-
}
|
|
394
|
-
const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
|
|
395
|
-
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
exports.signMetaTxCallExternalContract = signMetaTxCallExternalContract;
|
|
399
|
-
function signMetaTxCreateOfferWithCondition(args) {
|
|
400
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
-
common_1.utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
402
|
-
abortEarly: false
|
|
403
|
-
});
|
|
404
|
-
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
405
|
-
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
406
|
-
metadataStorage: args.metadataStorage,
|
|
407
|
-
theGraphStorage: args.theGraphStorage
|
|
408
|
-
});
|
|
409
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint256,uint256,uint256),uint256)", functionSignature: (0, interface_7.encodeCreateOfferWithCondition)(args.offerToCreate, args.condition) }));
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
exports.signMetaTxCreateOfferWithCondition = signMetaTxCreateOfferWithCondition;
|
|
413
|
-
function signMetaTxCommitToOffer(args) {
|
|
414
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
415
|
-
const functionName = "commitToOffer(address,uint256)";
|
|
416
|
-
const offerType = [
|
|
417
|
-
{ name: "buyer", type: "address" },
|
|
418
|
-
{ name: "offerId", type: "uint256" }
|
|
419
|
-
];
|
|
420
|
-
const metaTransactionType = [
|
|
421
|
-
{ name: "nonce", type: "uint256" },
|
|
422
|
-
{ name: "from", type: "address" },
|
|
423
|
-
{ name: "contractAddress", type: "address" },
|
|
424
|
-
{ name: "functionName", type: "string" },
|
|
425
|
-
{ name: "offerDetails", type: "MetaTxOfferDetails" }
|
|
426
|
-
];
|
|
427
|
-
const customSignatureType = {
|
|
428
|
-
MetaTxCommitToOffer: metaTransactionType,
|
|
429
|
-
MetaTxOfferDetails: offerType
|
|
430
|
-
};
|
|
431
|
-
const buyerAddress = yield args.web3Lib.getSignerAddress();
|
|
432
|
-
const message = {
|
|
433
|
-
nonce: args.nonce.toString(),
|
|
434
|
-
from: buyerAddress,
|
|
435
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
436
|
-
functionName,
|
|
437
|
-
offerDetails: {
|
|
438
|
-
buyer: buyerAddress,
|
|
439
|
-
offerId: args.offerId.toString()
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxCommitToOffer", message }));
|
|
443
|
-
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("commitToOffer", [buyerAddress, args.offerId]) });
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
exports.signMetaTxCommitToOffer = signMetaTxCommitToOffer;
|
|
447
|
-
function signMetaTxCancelVoucher(args) {
|
|
448
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
449
|
-
return makeExchangeMetaTxSigner("cancelVoucher(uint256)")(args);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
exports.signMetaTxCancelVoucher = signMetaTxCancelVoucher;
|
|
453
|
-
function signMetaTxRedeemVoucher(args) {
|
|
454
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
455
|
-
return makeExchangeMetaTxSigner("redeemVoucher(uint256)")(args);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
exports.signMetaTxRedeemVoucher = signMetaTxRedeemVoucher;
|
|
459
|
-
function signMetaTxCompleteExchange(args) {
|
|
460
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
-
return makeExchangeMetaTxSigner("completeExchange(uint256)")(args);
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
exports.signMetaTxCompleteExchange = signMetaTxCompleteExchange;
|
|
465
|
-
function signMetaTxRetractDispute(args) {
|
|
466
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
467
|
-
return makeExchangeMetaTxSigner("retractDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
exports.signMetaTxRetractDispute = signMetaTxRetractDispute;
|
|
471
|
-
function signMetaTxEscalateDispute(args) {
|
|
472
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
473
|
-
return makeExchangeMetaTxSigner("escalateDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
exports.signMetaTxEscalateDispute = signMetaTxEscalateDispute;
|
|
477
|
-
function signMetaTxRaiseDispute(args) {
|
|
478
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
-
return makeExchangeMetaTxSigner("raiseDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
exports.signMetaTxRaiseDispute = signMetaTxRaiseDispute;
|
|
483
|
-
function signMetaTxResolveDispute(args) {
|
|
484
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
485
|
-
const functionName = "resolveDispute(uint256,uint256,bytes32,bytes32,uint8)";
|
|
486
|
-
const disputeResolutionType = [
|
|
487
|
-
{ name: "exchangeId", type: "uint256" },
|
|
488
|
-
{ name: "buyerPercentBasisPoints", type: "uint256" },
|
|
489
|
-
{ name: "sigR", type: "bytes32" },
|
|
490
|
-
{ name: "sigS", type: "bytes32" },
|
|
491
|
-
{ name: "sigV", type: "uint8" }
|
|
492
|
-
];
|
|
493
|
-
const metaTransactionType = [
|
|
494
|
-
{ name: "nonce", type: "uint256" },
|
|
495
|
-
{ name: "from", type: "address" },
|
|
496
|
-
{ name: "contractAddress", type: "address" },
|
|
497
|
-
{ name: "functionName", type: "string" },
|
|
498
|
-
{ name: "disputeResolutionDetails", type: "MetaTxDisputeResolutionDetails" }
|
|
499
|
-
];
|
|
500
|
-
const customSignatureType = {
|
|
501
|
-
MetaTxDisputeResolution: metaTransactionType,
|
|
502
|
-
MetaTxDisputeResolutionDetails: disputeResolutionType
|
|
503
|
-
};
|
|
504
|
-
const message = {
|
|
505
|
-
nonce: args.nonce.toString(),
|
|
506
|
-
from: yield args.web3Lib.getSignerAddress(),
|
|
507
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
508
|
-
functionName,
|
|
509
|
-
disputeResolutionDetails: {
|
|
510
|
-
exchangeId: args.exchangeId.toString(),
|
|
511
|
-
buyerPercentBasisPoints: args.buyerPercent.toString(),
|
|
512
|
-
sigR: args.counterpartySig.r,
|
|
513
|
-
sigS: args.counterpartySig.s,
|
|
514
|
-
sigV: args.counterpartySig.v
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxDisputeResolution", message }));
|
|
518
|
-
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: interface_5.bosonDisputeHandlerIface.encodeFunctionData(
|
|
519
|
-
// remove params in brackets from string
|
|
520
|
-
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [
|
|
521
|
-
args.exchangeId,
|
|
522
|
-
args.buyerPercent,
|
|
523
|
-
args.counterpartySig.r,
|
|
524
|
-
args.counterpartySig.s,
|
|
525
|
-
args.counterpartySig.v
|
|
526
|
-
]) });
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
exports.signMetaTxResolveDispute = signMetaTxResolveDispute;
|
|
530
|
-
function signMetaTxExtendDisputeTimeout(args) {
|
|
531
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
532
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendDisputeTimeout(uint256,uint256)", functionSignature: interface_5.bosonDisputeHandlerIface.encodeFunctionData("extendDisputeTimeout", [args.exchangeId, args.newTimeout]) }));
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
exports.signMetaTxExtendDisputeTimeout = signMetaTxExtendDisputeTimeout;
|
|
536
|
-
function signMetaTxWithdrawFunds(args) {
|
|
537
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
538
|
-
const functionName = "withdrawFunds(uint256,address[],uint256[])";
|
|
539
|
-
const fundType = [
|
|
540
|
-
{ name: "entityId", type: "uint256" },
|
|
541
|
-
{ name: "tokenList", type: "address[]" },
|
|
542
|
-
{ name: "tokenAmounts", type: "uint256[]" }
|
|
543
|
-
];
|
|
544
|
-
const metaTransactionType = [
|
|
545
|
-
{ name: "nonce", type: "uint256" },
|
|
546
|
-
{ name: "from", type: "address" },
|
|
547
|
-
{ name: "contractAddress", type: "address" },
|
|
548
|
-
{ name: "functionName", type: "string" },
|
|
549
|
-
{ name: "fundDetails", type: "MetaTxFundDetails" }
|
|
550
|
-
];
|
|
551
|
-
const customSignatureType = {
|
|
552
|
-
MetaTxFund: metaTransactionType,
|
|
553
|
-
MetaTxFundDetails: fundType
|
|
554
|
-
};
|
|
555
|
-
const message = {
|
|
556
|
-
nonce: args.nonce.toString(),
|
|
557
|
-
from: yield args.web3Lib.getSignerAddress(),
|
|
558
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
559
|
-
functionName,
|
|
560
|
-
fundDetails: {
|
|
561
|
-
entityId: args.entityId.toString(),
|
|
562
|
-
tokenList: args.tokenList,
|
|
563
|
-
tokenAmounts: args.tokenAmounts.map((bn) => bn.toString())
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxFund", message }));
|
|
567
|
-
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: (0, interface_4.encodeWithdrawFunds)(args.entityId, args.tokenList, args.tokenAmounts) });
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
exports.signMetaTxWithdrawFunds = signMetaTxWithdrawFunds;
|
|
571
|
-
function signMetaTxDepositFunds(args) {
|
|
572
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
573
|
-
if (!(0, address_1.isAddress)(args.fundsTokenAddress)) {
|
|
574
|
-
throw new Error(`Invalid fundsTokenAddress: ${args.fundsTokenAddress}`);
|
|
575
|
-
}
|
|
576
|
-
if (args.fundsTokenAddress === constants_1.AddressZero) {
|
|
577
|
-
throw new Error(`Meta transaction can't be used to deposit native currency`);
|
|
578
|
-
}
|
|
579
|
-
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "depositFunds(uint256,address,uint256)", functionSignature: (0, interface_4.encodeDepositFunds)(args.sellerId, args.fundsTokenAddress, args.fundsAmount) }));
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
exports.signMetaTxDepositFunds = signMetaTxDepositFunds;
|
|
583
|
-
function makeExchangeMetaTxSigner(functionName, handlerIface = interface_2.bosonExchangeHandlerIface) {
|
|
584
|
-
return function signExchangeMetaTx(args) {
|
|
585
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
-
const exchangeType = [{ name: "exchangeId", type: "uint256" }];
|
|
587
|
-
const metaTransactionType = [
|
|
588
|
-
{ name: "nonce", type: "uint256" },
|
|
589
|
-
{ name: "from", type: "address" },
|
|
590
|
-
{ name: "contractAddress", type: "address" },
|
|
591
|
-
{ name: "functionName", type: "string" },
|
|
592
|
-
{ name: "exchangeDetails", type: "MetaTxExchangeDetails" }
|
|
593
|
-
];
|
|
594
|
-
const customSignatureType = {
|
|
595
|
-
MetaTxExchange: metaTransactionType,
|
|
596
|
-
MetaTxExchangeDetails: exchangeType
|
|
597
|
-
};
|
|
598
|
-
const buyerAddress = yield args.web3Lib.getSignerAddress();
|
|
599
|
-
const message = {
|
|
600
|
-
nonce: args.nonce.toString(),
|
|
601
|
-
from: buyerAddress,
|
|
602
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
603
|
-
functionName,
|
|
604
|
-
exchangeDetails: {
|
|
605
|
-
exchangeId: args.exchangeId.toString()
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxExchange", message }));
|
|
609
|
-
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: handlerIface.encodeFunctionData(
|
|
610
|
-
// remove params in brackets from string
|
|
611
|
-
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [args.exchangeId]) });
|
|
612
|
-
});
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
function relayMetaTransaction(args) {
|
|
616
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
617
|
-
const { chainId, contractAddress, metaTx } = args;
|
|
618
|
-
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
619
|
-
const relayTxResponse = yield biconomy.relayTransaction({
|
|
620
|
-
to: contractAddress,
|
|
621
|
-
params: [
|
|
622
|
-
metaTx.params.userAddress,
|
|
623
|
-
metaTx.params.functionName,
|
|
624
|
-
metaTx.params.functionSignature,
|
|
625
|
-
metaTx.params.nonce,
|
|
626
|
-
metaTx.params.sigR,
|
|
627
|
-
metaTx.params.sigS,
|
|
628
|
-
metaTx.params.sigV
|
|
629
|
-
],
|
|
630
|
-
from: metaTx.params.userAddress
|
|
631
|
-
});
|
|
632
|
-
return {
|
|
633
|
-
wait: () => __awaiter(this, void 0, void 0, function* () {
|
|
634
|
-
const waitResponse = yield biconomy.wait({
|
|
635
|
-
networkId: chainId,
|
|
636
|
-
transactionHash: relayTxResponse.txHash
|
|
637
|
-
});
|
|
638
|
-
const txHash = waitResponse.data.newHash;
|
|
639
|
-
const txReceipt = yield args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
640
|
-
console.log("[relayBiconomyMetaTransaction.wait] txReceipt", txReceipt);
|
|
641
|
-
return {
|
|
642
|
-
to: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.to) || contractAddress,
|
|
643
|
-
from: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.from) || metaTx.params.userAddress,
|
|
644
|
-
transactionHash: txHash,
|
|
645
|
-
logs: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.logs) || [],
|
|
646
|
-
effectiveGasPrice: bignumber_1.BigNumber.from(waitResponse.data.newGasPrice)
|
|
647
|
-
};
|
|
648
|
-
}),
|
|
649
|
-
hash: relayTxResponse.txHash
|
|
650
|
-
};
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
exports.relayMetaTransaction = relayMetaTransaction;
|
|
654
|
-
function getResubmitted(args) {
|
|
655
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
656
|
-
const { chainId, metaTx } = args;
|
|
657
|
-
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
658
|
-
const retriedHashesResponse = yield biconomy.getResubmitted({
|
|
659
|
-
networkId: chainId,
|
|
660
|
-
transactionHash: metaTx.originalHash
|
|
661
|
-
});
|
|
662
|
-
return retriedHashesResponse.data;
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
exports.getResubmitted = getResubmitted;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getResubmitted = exports.relayMetaTransaction = exports.signMetaTxDepositFunds = exports.signMetaTxWithdrawFunds = exports.signMetaTxExtendDisputeTimeout = exports.signMetaTxResolveDispute = exports.signMetaTxRaiseDispute = exports.signMetaTxEscalateDispute = exports.signMetaTxRetractDispute = exports.signMetaTxCompleteExchange = exports.signMetaTxRedeemVoucher = exports.signMetaTxCancelVoucher = exports.signMetaTxCommitToOffer = exports.signMetaTxCreateOfferWithCondition = exports.signMetaTxCallExternalContract = exports.signMetaTxSetApprovalForAllToContract = exports.signMetaTxSetApprovalForAll = exports.signMetaTxPreMint = exports.signMetaTxReserveRange = exports.signMetaTxCreateGroup = exports.signMetaTxRevokeVoucher = exports.signMetaTxExpireVoucher = exports.signMetaTxCompleteExchangeBatch = exports.signMetaTxExtendOfferBatch = exports.signMetaTxExtendOffer = exports.signMetaTxVoidOfferBatch = exports.signMetaTxVoidOffer = exports.signMetaTxCreateOfferBatch = exports.signMetaTxCreateOffer = exports.signMetaTxOptInToSellerUpdate = exports.signMetaTxUpdateSeller = exports.signMetaTxCreateSeller = exports.relayBiconomyMetaTransaction = exports.signBiconomyVoucherMetaTx = exports.signVoucherMetaTx = exports.signMetaTx = void 0;
|
|
13
|
+
const common_1 = require("@bosonprotocol/common");
|
|
14
|
+
const storage_1 = require("../offers/storage");
|
|
15
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
16
|
+
const interface_1 = require("../accounts/interface");
|
|
17
|
+
const interface_2 = require("../exchanges/interface");
|
|
18
|
+
const interface_3 = require("../offers/interface");
|
|
19
|
+
const signature_1 = require("../utils/signature");
|
|
20
|
+
const biconomy_1 = require("./biconomy");
|
|
21
|
+
const address_1 = require("@ethersproject/address");
|
|
22
|
+
const constants_1 = require("@ethersproject/constants");
|
|
23
|
+
const interface_4 = require("../funds/interface");
|
|
24
|
+
const interface_5 = require("../disputes/interface");
|
|
25
|
+
const interface_6 = require("../groups/interface");
|
|
26
|
+
const interface_7 = require("../orchestration/interface");
|
|
27
|
+
const interface_8 = require("../voucher/interface");
|
|
28
|
+
const keccak256_1 = require("@ethersproject/keccak256");
|
|
29
|
+
const hash_1 = require("@ethersproject/hash");
|
|
30
|
+
const abi_1 = require("@ethersproject/abi");
|
|
31
|
+
const handler_1 = require("../forwarder/handler");
|
|
32
|
+
const handler_2 = require("../voucher/handler");
|
|
33
|
+
function signMetaTx(args) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const metaTransactionType = [
|
|
36
|
+
{ name: "nonce", type: "uint256" },
|
|
37
|
+
{ name: "from", type: "address" },
|
|
38
|
+
{ name: "contractAddress", type: "address" },
|
|
39
|
+
{ name: "functionName", type: "string" },
|
|
40
|
+
{ name: "functionSignature", type: "bytes" }
|
|
41
|
+
];
|
|
42
|
+
const customSignatureType = {
|
|
43
|
+
MetaTransaction: metaTransactionType
|
|
44
|
+
};
|
|
45
|
+
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
46
|
+
const message = {
|
|
47
|
+
nonce: args.nonce,
|
|
48
|
+
from: signerAddress,
|
|
49
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
50
|
+
functionName: args.functionName,
|
|
51
|
+
functionSignature: args.functionSignature
|
|
52
|
+
};
|
|
53
|
+
const signature = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTransaction", message }));
|
|
54
|
+
return Object.assign({ functionName: args.functionName, functionSignature: args.functionSignature }, signature);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.signMetaTx = signMetaTx;
|
|
58
|
+
function signVoucherMetaTx(args) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const forwardType = [
|
|
61
|
+
{ name: "from", type: "address" },
|
|
62
|
+
{ name: "to", type: "address" },
|
|
63
|
+
{ name: "nonce", type: "uint256" },
|
|
64
|
+
{ name: "data", type: "bytes" }
|
|
65
|
+
];
|
|
66
|
+
const customSignatureType = {
|
|
67
|
+
EIP712Domain: [
|
|
68
|
+
{ name: "name", type: "string" },
|
|
69
|
+
{ name: "version", type: "string" },
|
|
70
|
+
{ name: "chainId", type: "uint256" },
|
|
71
|
+
{ name: "verifyingContract", type: "address" }
|
|
72
|
+
],
|
|
73
|
+
ForwardRequest: forwardType
|
|
74
|
+
};
|
|
75
|
+
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
76
|
+
const chainId = yield args.web3Lib.getChainId();
|
|
77
|
+
const nonce = yield (0, handler_1.getNonce)({
|
|
78
|
+
contractAddress: args.forwarderAddress,
|
|
79
|
+
user: signerAddress,
|
|
80
|
+
web3Lib: args.web3Lib,
|
|
81
|
+
forwarderAbi: args.forwarderAbi
|
|
82
|
+
});
|
|
83
|
+
const message = {
|
|
84
|
+
from: signerAddress,
|
|
85
|
+
to: args.bosonVoucherAddress,
|
|
86
|
+
nonce,
|
|
87
|
+
data: args.functionSignature
|
|
88
|
+
};
|
|
89
|
+
const signature = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.forwarderAddress, customSignatureType, primaryType: "ForwardRequest", message, customDomainData: {
|
|
90
|
+
name: "MockForwarder",
|
|
91
|
+
version: "0.0.1",
|
|
92
|
+
chainId,
|
|
93
|
+
salt: undefined
|
|
94
|
+
} }));
|
|
95
|
+
return Object.assign({ to: message.to, functionSignature: args.functionSignature, request: message }, signature);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
exports.signVoucherMetaTx = signVoucherMetaTx;
|
|
99
|
+
function signBiconomyVoucherMetaTx(args) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const customSignatureType = {
|
|
102
|
+
EIP712Domain: [
|
|
103
|
+
{ name: "name", type: "string" },
|
|
104
|
+
{ name: "version", type: "string" },
|
|
105
|
+
// { name: "chainId", type: "uint256" },
|
|
106
|
+
// { name: "verifyingContract", type: "address" }
|
|
107
|
+
{ name: "verifyingContract", type: "address" },
|
|
108
|
+
{ name: "salt", type: "bytes32" }
|
|
109
|
+
],
|
|
110
|
+
ERC20ForwardRequest: [
|
|
111
|
+
{ name: "from", type: "address" },
|
|
112
|
+
{ name: "to", type: "address" },
|
|
113
|
+
{ name: "token", type: "address" },
|
|
114
|
+
{ name: "txGas", type: "uint256" },
|
|
115
|
+
{ name: "tokenGasPrice", type: "uint256" },
|
|
116
|
+
{ name: "batchId", type: "uint256" },
|
|
117
|
+
{ name: "batchNonce", type: "uint256" },
|
|
118
|
+
{ name: "deadline", type: "uint256" },
|
|
119
|
+
{ name: "data", type: "bytes" }
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
const signerAddress = yield args.web3Lib.getSignerAddress();
|
|
123
|
+
const chainId = yield args.web3Lib.getChainId();
|
|
124
|
+
// Check which forwarder needs to be used for the contract
|
|
125
|
+
const biconomyForwarderDomainDetails = yield new biconomy_1.Biconomy(args.relayerUrl).getForwarderDomainDetails({ chainId });
|
|
126
|
+
const biconomyForwarderDomainData = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
try {
|
|
128
|
+
for (const bFDD of Object.values(biconomyForwarderDomainDetails)) {
|
|
129
|
+
const ret = yield (0, handler_2.isTrustedForwarder)({
|
|
130
|
+
forwarder: bFDD.verifyingContract,
|
|
131
|
+
contractAddress: args.bosonVoucherAddress,
|
|
132
|
+
web3Lib: args.web3Lib
|
|
133
|
+
});
|
|
134
|
+
if (ret) {
|
|
135
|
+
resolve(bFDD);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
resolve(undefined);
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
reject(e);
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
if (!biconomyForwarderDomainData) {
|
|
145
|
+
throw `Unable to find the trusted forwarder for BosonVoucher contract ${args.bosonVoucherAddress}`;
|
|
146
|
+
}
|
|
147
|
+
const nonce = yield (0, handler_1.getNonce)({
|
|
148
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
149
|
+
user: signerAddress,
|
|
150
|
+
web3Lib: args.web3Lib,
|
|
151
|
+
batchId: args.batchId,
|
|
152
|
+
forwarderAbi: args.forwarderAbi
|
|
153
|
+
});
|
|
154
|
+
const message = {
|
|
155
|
+
from: signerAddress,
|
|
156
|
+
to: args.bosonVoucherAddress,
|
|
157
|
+
token: "0x0000000000000000000000000000000000000000",
|
|
158
|
+
txGas: args.txGas,
|
|
159
|
+
tokenGasPrice: "0",
|
|
160
|
+
batchId: args.batchId,
|
|
161
|
+
batchNonce: nonce,
|
|
162
|
+
deadline: Math.floor(Date.now() / 1000 + 3600),
|
|
163
|
+
data: args.functionSignature
|
|
164
|
+
};
|
|
165
|
+
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { chainId, verifyingContractAddress: biconomyForwarderDomainData.verifyingContract, customSignatureType, primaryType: "ERC20ForwardRequest", message, customDomainData: Object.assign({}, biconomyForwarderDomainData
|
|
166
|
+
// chainId
|
|
167
|
+
// salt: undefined
|
|
168
|
+
) }));
|
|
169
|
+
const signature = signatureParams.signature;
|
|
170
|
+
const getDomainSeparator = () => __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const domainData = biconomyForwarderDomainData;
|
|
172
|
+
const domainSeparator = (0, keccak256_1.keccak256)(abi_1.defaultAbiCoder.encode(["bytes32", "bytes32", "bytes32", "address", "bytes32"], [
|
|
173
|
+
(0, hash_1.id)("EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"),
|
|
174
|
+
(0, hash_1.id)(domainData.name),
|
|
175
|
+
(0, hash_1.id)(domainData.version),
|
|
176
|
+
domainData.verifyingContract,
|
|
177
|
+
domainData.salt
|
|
178
|
+
]));
|
|
179
|
+
return domainSeparator;
|
|
180
|
+
});
|
|
181
|
+
const domainSeparator = yield getDomainSeparator();
|
|
182
|
+
// verify signature
|
|
183
|
+
const signatureVerified = yield (0, handler_1.verifyEIP712)({
|
|
184
|
+
request: message,
|
|
185
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
186
|
+
web3Lib: args.web3Lib,
|
|
187
|
+
domainSeparator,
|
|
188
|
+
forwarderAbi: args.forwarderAbi,
|
|
189
|
+
signature
|
|
190
|
+
});
|
|
191
|
+
if (!signatureVerified) {
|
|
192
|
+
throw `Signature is not verified`;
|
|
193
|
+
}
|
|
194
|
+
return Object.assign(Object.assign({ to: message.to, domainSeparator, request: message }, signatureParams), { signature, functionSignature: args.functionSignature });
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
exports.signBiconomyVoucherMetaTx = signBiconomyVoucherMetaTx;
|
|
198
|
+
function relayBiconomyMetaTransaction(args) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
const { chainId, contractAddress, metaTx } = args;
|
|
201
|
+
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
202
|
+
const relayTxResponse = yield biconomy.relayTransaction({
|
|
203
|
+
to: contractAddress,
|
|
204
|
+
params: [
|
|
205
|
+
metaTx.params.request,
|
|
206
|
+
metaTx.params.domainSeparator,
|
|
207
|
+
metaTx.params.signature
|
|
208
|
+
],
|
|
209
|
+
from: metaTx.params.userAddress,
|
|
210
|
+
signatureType: "EIP712_SIGN"
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
wait: () => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const waitResponse = yield biconomy.wait({
|
|
215
|
+
networkId: chainId,
|
|
216
|
+
transactionHash: relayTxResponse.txHash
|
|
217
|
+
});
|
|
218
|
+
const txHash = waitResponse.data.newHash;
|
|
219
|
+
const txReceipt = yield args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
220
|
+
return {
|
|
221
|
+
to: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.to) || contractAddress,
|
|
222
|
+
from: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.from) || metaTx.params.userAddress,
|
|
223
|
+
transactionHash: txHash,
|
|
224
|
+
logs: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.logs) || [],
|
|
225
|
+
effectiveGasPrice: bignumber_1.BigNumber.from(waitResponse.data.newGasPrice)
|
|
226
|
+
};
|
|
227
|
+
}),
|
|
228
|
+
hash: relayTxResponse.txHash
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
exports.relayBiconomyMetaTransaction = relayBiconomyMetaTransaction;
|
|
233
|
+
function signMetaTxCreateSeller(args) {
|
|
234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
236
|
+
metadataUriOrHash: args.createSellerArgs.metadataUri,
|
|
237
|
+
metadataStorage: args.metadataStorage,
|
|
238
|
+
theGraphStorage: args.theGraphStorage
|
|
239
|
+
});
|
|
240
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256))", functionSignature: (0, interface_1.encodeCreateSeller)(args.createSellerArgs) }));
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
exports.signMetaTxCreateSeller = signMetaTxCreateSeller;
|
|
244
|
+
function signMetaTxUpdateSeller(args) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
247
|
+
metadataUriOrHash: args.updateSellerArgs.metadataUri,
|
|
248
|
+
metadataStorage: args.metadataStorage,
|
|
249
|
+
theGraphStorage: args.theGraphStorage
|
|
250
|
+
});
|
|
251
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "updateSeller((uint256,address,address,address,address,bool,string),(uint256,uint8))", functionSignature: (0, interface_1.encodeUpdateSeller)(args.updateSellerArgs) }));
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
exports.signMetaTxUpdateSeller = signMetaTxUpdateSeller;
|
|
255
|
+
function signMetaTxOptInToSellerUpdate(args) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "optInToSellerUpdate(uint256,uint8[])", functionSignature: (0, interface_1.encodeOptInToSellerUpdate)(args.optInToSellerUpdateArgs) }));
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
exports.signMetaTxOptInToSellerUpdate = signMetaTxOptInToSellerUpdate;
|
|
261
|
+
function signMetaTxCreateOffer(args) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
common_1.utils.validation.createOfferArgsSchema.validateSync(args.createOfferArgs, {
|
|
264
|
+
abortEarly: false
|
|
265
|
+
});
|
|
266
|
+
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
267
|
+
metadataUriOrHash: args.createOfferArgs.metadataUri,
|
|
268
|
+
metadataStorage: args.metadataStorage,
|
|
269
|
+
theGraphStorage: args.theGraphStorage
|
|
270
|
+
});
|
|
271
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)", functionSignature: (0, interface_3.encodeCreateOffer)(args.createOfferArgs) }));
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
exports.signMetaTxCreateOffer = signMetaTxCreateOffer;
|
|
275
|
+
function signMetaTxCreateOfferBatch(args) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
for (const offerToCreate of args.createOffersArgs) {
|
|
278
|
+
common_1.utils.validation.createOfferArgsSchema.validateSync(offerToCreate, {
|
|
279
|
+
abortEarly: false
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
yield Promise.all(args.createOffersArgs.map((offerToCreate) => (0, storage_1.storeMetadataOnTheGraph)({
|
|
283
|
+
metadataUriOrHash: offerToCreate.metadataUri,
|
|
284
|
+
metadataStorage: args.metadataStorage,
|
|
285
|
+
theGraphStorage: args.theGraphStorage
|
|
286
|
+
})));
|
|
287
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])", functionSignature: (0, interface_3.encodeCreateOfferBatch)(args.createOffersArgs) }));
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
exports.signMetaTxCreateOfferBatch = signMetaTxCreateOfferBatch;
|
|
291
|
+
function signMetaTxVoidOffer(args) {
|
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "voidOffer(uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("voidOffer", [
|
|
294
|
+
args.offerId
|
|
295
|
+
]) }));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
exports.signMetaTxVoidOffer = signMetaTxVoidOffer;
|
|
299
|
+
function signMetaTxVoidOfferBatch(args) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "voidOfferBatch(uint256[])", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("voidOfferBatch", [args.offerIds]) }));
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
exports.signMetaTxVoidOfferBatch = signMetaTxVoidOfferBatch;
|
|
305
|
+
function signMetaTxExtendOffer(args) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendOffer(uint256,uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("extendOffer", [args.offerId, args.validUntil]) }));
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
exports.signMetaTxExtendOffer = signMetaTxExtendOffer;
|
|
311
|
+
function signMetaTxExtendOfferBatch(args) {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendOfferBatch(uint256[],uint256)", functionSignature: interface_3.bosonOfferHandlerIface.encodeFunctionData("extendOfferBatch", [args.offerIds, args.validUntil]) }));
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
exports.signMetaTxExtendOfferBatch = signMetaTxExtendOfferBatch;
|
|
317
|
+
function signMetaTxCompleteExchangeBatch(args) {
|
|
318
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
319
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "completeExchangeBatch(uint256[])", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("completeExchangeBatch", [args.exchangeIds]) }));
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
exports.signMetaTxCompleteExchangeBatch = signMetaTxCompleteExchangeBatch;
|
|
323
|
+
function signMetaTxExpireVoucher(args) {
|
|
324
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "expireVoucher(uint256)", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("expireVoucher", [args.exchangeId]) }));
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
exports.signMetaTxExpireVoucher = signMetaTxExpireVoucher;
|
|
329
|
+
function signMetaTxRevokeVoucher(args) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "revokeVoucher(uint256)", functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("revokeVoucher", [args.exchangeId]) }));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
exports.signMetaTxRevokeVoucher = signMetaTxRevokeVoucher;
|
|
335
|
+
function signMetaTxCreateGroup(args) {
|
|
336
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))", functionSignature: (0, interface_6.encodeCreateGroup)(args.createGroupArgs) }));
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
exports.signMetaTxCreateGroup = signMetaTxCreateGroup;
|
|
341
|
+
function signMetaTxReserveRange(args) {
|
|
342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "reserveRange(uint256,uint256,address)", functionSignature: (0, interface_3.encodeReserveRange)(args.offerId, args.length, args.to) }));
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
exports.signMetaTxReserveRange = signMetaTxReserveRange;
|
|
347
|
+
function signMetaTxPreMint(args) {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
350
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
351
|
+
const functionSignature = (0, interface_8.encodePreMint)(args.offerId, args.amount);
|
|
352
|
+
if (isLocal) {
|
|
353
|
+
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
354
|
+
}
|
|
355
|
+
const txGas = 200000 + bignumber_1.BigNumber.from(args.amount).mul(2500).toNumber(); // ~(180000 + 2250*N) estimation on 2023/02/03
|
|
356
|
+
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
exports.signMetaTxPreMint = signMetaTxPreMint;
|
|
360
|
+
function signMetaTxSetApprovalForAll(args) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
363
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
364
|
+
const functionSignature = (0, interface_8.encodeSetApprovalForAll)(args.operator, args.approved);
|
|
365
|
+
if (isLocal) {
|
|
366
|
+
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
367
|
+
}
|
|
368
|
+
const txGas = 100000; // ~70000 estimation on 2023/02/03
|
|
369
|
+
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
exports.signMetaTxSetApprovalForAll = signMetaTxSetApprovalForAll;
|
|
373
|
+
function signMetaTxSetApprovalForAllToContract(args, overrides = {}) {
|
|
374
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
+
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
376
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
377
|
+
const functionSignature = (0, interface_8.encodeSetApprovalForAllToContract)(args.operator, args.approved);
|
|
378
|
+
if (isLocal) {
|
|
379
|
+
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
380
|
+
}
|
|
381
|
+
const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
|
|
382
|
+
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
exports.signMetaTxSetApprovalForAllToContract = signMetaTxSetApprovalForAllToContract;
|
|
386
|
+
function signMetaTxCallExternalContract(args, overrides = {}) {
|
|
387
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
388
|
+
const localConfig = common_1.defaultConfigs.find((config) => config.envName === "local");
|
|
389
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
390
|
+
const functionSignature = (0, interface_8.encodeCallExternalContract)(args.to, args.data);
|
|
391
|
+
if (isLocal) {
|
|
392
|
+
return signVoucherMetaTx(Object.assign(Object.assign({}, args), { forwarderAddress: args.forwarderAddress, functionSignature, forwarderAbi: args.forwarderAbi }));
|
|
393
|
+
}
|
|
394
|
+
const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
|
|
395
|
+
return signBiconomyVoucherMetaTx(Object.assign(Object.assign({}, args), { functionSignature, forwarderAbi: args.forwarderAbi, batchId: args.batchId || "0", txGas }));
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
exports.signMetaTxCallExternalContract = signMetaTxCallExternalContract;
|
|
399
|
+
function signMetaTxCreateOfferWithCondition(args) {
|
|
400
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
common_1.utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
402
|
+
abortEarly: false
|
|
403
|
+
});
|
|
404
|
+
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
405
|
+
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
406
|
+
metadataStorage: args.metadataStorage,
|
|
407
|
+
theGraphStorage: args.theGraphStorage
|
|
408
|
+
});
|
|
409
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint256,uint256,uint256),uint256)", functionSignature: (0, interface_7.encodeCreateOfferWithCondition)(args.offerToCreate, args.condition) }));
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
exports.signMetaTxCreateOfferWithCondition = signMetaTxCreateOfferWithCondition;
|
|
413
|
+
function signMetaTxCommitToOffer(args) {
|
|
414
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
415
|
+
const functionName = "commitToOffer(address,uint256)";
|
|
416
|
+
const offerType = [
|
|
417
|
+
{ name: "buyer", type: "address" },
|
|
418
|
+
{ name: "offerId", type: "uint256" }
|
|
419
|
+
];
|
|
420
|
+
const metaTransactionType = [
|
|
421
|
+
{ name: "nonce", type: "uint256" },
|
|
422
|
+
{ name: "from", type: "address" },
|
|
423
|
+
{ name: "contractAddress", type: "address" },
|
|
424
|
+
{ name: "functionName", type: "string" },
|
|
425
|
+
{ name: "offerDetails", type: "MetaTxOfferDetails" }
|
|
426
|
+
];
|
|
427
|
+
const customSignatureType = {
|
|
428
|
+
MetaTxCommitToOffer: metaTransactionType,
|
|
429
|
+
MetaTxOfferDetails: offerType
|
|
430
|
+
};
|
|
431
|
+
const buyerAddress = yield args.web3Lib.getSignerAddress();
|
|
432
|
+
const message = {
|
|
433
|
+
nonce: args.nonce.toString(),
|
|
434
|
+
from: buyerAddress,
|
|
435
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
436
|
+
functionName,
|
|
437
|
+
offerDetails: {
|
|
438
|
+
buyer: buyerAddress,
|
|
439
|
+
offerId: args.offerId.toString()
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxCommitToOffer", message }));
|
|
443
|
+
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: interface_2.bosonExchangeHandlerIface.encodeFunctionData("commitToOffer", [buyerAddress, args.offerId]) });
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
exports.signMetaTxCommitToOffer = signMetaTxCommitToOffer;
|
|
447
|
+
function signMetaTxCancelVoucher(args) {
|
|
448
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
449
|
+
return makeExchangeMetaTxSigner("cancelVoucher(uint256)")(args);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
exports.signMetaTxCancelVoucher = signMetaTxCancelVoucher;
|
|
453
|
+
function signMetaTxRedeemVoucher(args) {
|
|
454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
455
|
+
return makeExchangeMetaTxSigner("redeemVoucher(uint256)")(args);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
exports.signMetaTxRedeemVoucher = signMetaTxRedeemVoucher;
|
|
459
|
+
function signMetaTxCompleteExchange(args) {
|
|
460
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
+
return makeExchangeMetaTxSigner("completeExchange(uint256)")(args);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
exports.signMetaTxCompleteExchange = signMetaTxCompleteExchange;
|
|
465
|
+
function signMetaTxRetractDispute(args) {
|
|
466
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
467
|
+
return makeExchangeMetaTxSigner("retractDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
exports.signMetaTxRetractDispute = signMetaTxRetractDispute;
|
|
471
|
+
function signMetaTxEscalateDispute(args) {
|
|
472
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
473
|
+
return makeExchangeMetaTxSigner("escalateDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
exports.signMetaTxEscalateDispute = signMetaTxEscalateDispute;
|
|
477
|
+
function signMetaTxRaiseDispute(args) {
|
|
478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
return makeExchangeMetaTxSigner("raiseDispute(uint256)", interface_5.bosonDisputeHandlerIface)(args);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
exports.signMetaTxRaiseDispute = signMetaTxRaiseDispute;
|
|
483
|
+
function signMetaTxResolveDispute(args) {
|
|
484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
485
|
+
const functionName = "resolveDispute(uint256,uint256,bytes32,bytes32,uint8)";
|
|
486
|
+
const disputeResolutionType = [
|
|
487
|
+
{ name: "exchangeId", type: "uint256" },
|
|
488
|
+
{ name: "buyerPercentBasisPoints", type: "uint256" },
|
|
489
|
+
{ name: "sigR", type: "bytes32" },
|
|
490
|
+
{ name: "sigS", type: "bytes32" },
|
|
491
|
+
{ name: "sigV", type: "uint8" }
|
|
492
|
+
];
|
|
493
|
+
const metaTransactionType = [
|
|
494
|
+
{ name: "nonce", type: "uint256" },
|
|
495
|
+
{ name: "from", type: "address" },
|
|
496
|
+
{ name: "contractAddress", type: "address" },
|
|
497
|
+
{ name: "functionName", type: "string" },
|
|
498
|
+
{ name: "disputeResolutionDetails", type: "MetaTxDisputeResolutionDetails" }
|
|
499
|
+
];
|
|
500
|
+
const customSignatureType = {
|
|
501
|
+
MetaTxDisputeResolution: metaTransactionType,
|
|
502
|
+
MetaTxDisputeResolutionDetails: disputeResolutionType
|
|
503
|
+
};
|
|
504
|
+
const message = {
|
|
505
|
+
nonce: args.nonce.toString(),
|
|
506
|
+
from: yield args.web3Lib.getSignerAddress(),
|
|
507
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
508
|
+
functionName,
|
|
509
|
+
disputeResolutionDetails: {
|
|
510
|
+
exchangeId: args.exchangeId.toString(),
|
|
511
|
+
buyerPercentBasisPoints: args.buyerPercent.toString(),
|
|
512
|
+
sigR: args.counterpartySig.r,
|
|
513
|
+
sigS: args.counterpartySig.s,
|
|
514
|
+
sigV: args.counterpartySig.v
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxDisputeResolution", message }));
|
|
518
|
+
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: interface_5.bosonDisputeHandlerIface.encodeFunctionData(
|
|
519
|
+
// remove params in brackets from string
|
|
520
|
+
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [
|
|
521
|
+
args.exchangeId,
|
|
522
|
+
args.buyerPercent,
|
|
523
|
+
args.counterpartySig.r,
|
|
524
|
+
args.counterpartySig.s,
|
|
525
|
+
args.counterpartySig.v
|
|
526
|
+
]) });
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
exports.signMetaTxResolveDispute = signMetaTxResolveDispute;
|
|
530
|
+
function signMetaTxExtendDisputeTimeout(args) {
|
|
531
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
532
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "extendDisputeTimeout(uint256,uint256)", functionSignature: interface_5.bosonDisputeHandlerIface.encodeFunctionData("extendDisputeTimeout", [args.exchangeId, args.newTimeout]) }));
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
exports.signMetaTxExtendDisputeTimeout = signMetaTxExtendDisputeTimeout;
|
|
536
|
+
function signMetaTxWithdrawFunds(args) {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
538
|
+
const functionName = "withdrawFunds(uint256,address[],uint256[])";
|
|
539
|
+
const fundType = [
|
|
540
|
+
{ name: "entityId", type: "uint256" },
|
|
541
|
+
{ name: "tokenList", type: "address[]" },
|
|
542
|
+
{ name: "tokenAmounts", type: "uint256[]" }
|
|
543
|
+
];
|
|
544
|
+
const metaTransactionType = [
|
|
545
|
+
{ name: "nonce", type: "uint256" },
|
|
546
|
+
{ name: "from", type: "address" },
|
|
547
|
+
{ name: "contractAddress", type: "address" },
|
|
548
|
+
{ name: "functionName", type: "string" },
|
|
549
|
+
{ name: "fundDetails", type: "MetaTxFundDetails" }
|
|
550
|
+
];
|
|
551
|
+
const customSignatureType = {
|
|
552
|
+
MetaTxFund: metaTransactionType,
|
|
553
|
+
MetaTxFundDetails: fundType
|
|
554
|
+
};
|
|
555
|
+
const message = {
|
|
556
|
+
nonce: args.nonce.toString(),
|
|
557
|
+
from: yield args.web3Lib.getSignerAddress(),
|
|
558
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
559
|
+
functionName,
|
|
560
|
+
fundDetails: {
|
|
561
|
+
entityId: args.entityId.toString(),
|
|
562
|
+
tokenList: args.tokenList,
|
|
563
|
+
tokenAmounts: args.tokenAmounts.map((bn) => bn.toString())
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxFund", message }));
|
|
567
|
+
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: (0, interface_4.encodeWithdrawFunds)(args.entityId, args.tokenList, args.tokenAmounts) });
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
exports.signMetaTxWithdrawFunds = signMetaTxWithdrawFunds;
|
|
571
|
+
function signMetaTxDepositFunds(args) {
|
|
572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
573
|
+
if (!(0, address_1.isAddress)(args.fundsTokenAddress)) {
|
|
574
|
+
throw new Error(`Invalid fundsTokenAddress: ${args.fundsTokenAddress}`);
|
|
575
|
+
}
|
|
576
|
+
if (args.fundsTokenAddress === constants_1.AddressZero) {
|
|
577
|
+
throw new Error(`Meta transaction can't be used to deposit native currency`);
|
|
578
|
+
}
|
|
579
|
+
return signMetaTx(Object.assign(Object.assign({}, args), { functionName: "depositFunds(uint256,address,uint256)", functionSignature: (0, interface_4.encodeDepositFunds)(args.sellerId, args.fundsTokenAddress, args.fundsAmount) }));
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
exports.signMetaTxDepositFunds = signMetaTxDepositFunds;
|
|
583
|
+
function makeExchangeMetaTxSigner(functionName, handlerIface = interface_2.bosonExchangeHandlerIface) {
|
|
584
|
+
return function signExchangeMetaTx(args) {
|
|
585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
const exchangeType = [{ name: "exchangeId", type: "uint256" }];
|
|
587
|
+
const metaTransactionType = [
|
|
588
|
+
{ name: "nonce", type: "uint256" },
|
|
589
|
+
{ name: "from", type: "address" },
|
|
590
|
+
{ name: "contractAddress", type: "address" },
|
|
591
|
+
{ name: "functionName", type: "string" },
|
|
592
|
+
{ name: "exchangeDetails", type: "MetaTxExchangeDetails" }
|
|
593
|
+
];
|
|
594
|
+
const customSignatureType = {
|
|
595
|
+
MetaTxExchange: metaTransactionType,
|
|
596
|
+
MetaTxExchangeDetails: exchangeType
|
|
597
|
+
};
|
|
598
|
+
const buyerAddress = yield args.web3Lib.getSignerAddress();
|
|
599
|
+
const message = {
|
|
600
|
+
nonce: args.nonce.toString(),
|
|
601
|
+
from: buyerAddress,
|
|
602
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
603
|
+
functionName,
|
|
604
|
+
exchangeDetails: {
|
|
605
|
+
exchangeId: args.exchangeId.toString()
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
const signatureParams = yield (0, signature_1.prepareDataSignatureParameters)(Object.assign(Object.assign({}, args), { verifyingContractAddress: args.metaTxHandlerAddress, customSignatureType, primaryType: "MetaTxExchange", message }));
|
|
609
|
+
return Object.assign(Object.assign({}, signatureParams), { functionName, functionSignature: handlerIface.encodeFunctionData(
|
|
610
|
+
// remove params in brackets from string
|
|
611
|
+
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [args.exchangeId]) });
|
|
612
|
+
});
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function relayMetaTransaction(args) {
|
|
616
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
617
|
+
const { chainId, contractAddress, metaTx } = args;
|
|
618
|
+
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
619
|
+
const relayTxResponse = yield biconomy.relayTransaction({
|
|
620
|
+
to: contractAddress,
|
|
621
|
+
params: [
|
|
622
|
+
metaTx.params.userAddress,
|
|
623
|
+
metaTx.params.functionName,
|
|
624
|
+
metaTx.params.functionSignature,
|
|
625
|
+
metaTx.params.nonce,
|
|
626
|
+
metaTx.params.sigR,
|
|
627
|
+
metaTx.params.sigS,
|
|
628
|
+
metaTx.params.sigV
|
|
629
|
+
],
|
|
630
|
+
from: metaTx.params.userAddress
|
|
631
|
+
});
|
|
632
|
+
return {
|
|
633
|
+
wait: () => __awaiter(this, void 0, void 0, function* () {
|
|
634
|
+
const waitResponse = yield biconomy.wait({
|
|
635
|
+
networkId: chainId,
|
|
636
|
+
transactionHash: relayTxResponse.txHash
|
|
637
|
+
});
|
|
638
|
+
const txHash = waitResponse.data.newHash;
|
|
639
|
+
const txReceipt = yield args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
640
|
+
console.log("[relayBiconomyMetaTransaction.wait] txReceipt", txReceipt);
|
|
641
|
+
return {
|
|
642
|
+
to: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.to) || contractAddress,
|
|
643
|
+
from: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.from) || metaTx.params.userAddress,
|
|
644
|
+
transactionHash: txHash,
|
|
645
|
+
logs: (txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.logs) || [],
|
|
646
|
+
effectiveGasPrice: bignumber_1.BigNumber.from(waitResponse.data.newGasPrice)
|
|
647
|
+
};
|
|
648
|
+
}),
|
|
649
|
+
hash: relayTxResponse.txHash
|
|
650
|
+
};
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
exports.relayMetaTransaction = relayMetaTransaction;
|
|
654
|
+
function getResubmitted(args) {
|
|
655
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
656
|
+
const { chainId, metaTx } = args;
|
|
657
|
+
const biconomy = new biconomy_1.Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
658
|
+
const retriedHashesResponse = yield biconomy.getResubmitted({
|
|
659
|
+
networkId: chainId,
|
|
660
|
+
transactionHash: metaTx.originalHash
|
|
661
|
+
});
|
|
662
|
+
return retriedHashesResponse.data;
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
exports.getResubmitted = getResubmitted;
|
|
666
666
|
//# sourceMappingURL=handler.js.map
|