@agoric/orchestration 0.2.0 → 0.2.1-upgrade-23-dev-bd79330.0.bd79330
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/index.js +0 -4
- package/package.json +27 -27
- package/src/axelar-types.d.ts +2 -0
- package/src/axelar-types.d.ts.map +1 -1
- package/src/axelar-types.js +2 -0
- package/src/cctp-chain-info.js +4 -1
- package/src/chain-info.d.ts +21 -6
- package/src/chain-info.d.ts.map +1 -1
- package/src/chain-info.js +9 -8
- package/src/cosmos-api.d.ts +102 -29
- package/src/cosmos-api.d.ts.map +1 -1
- package/src/cosmos-api.js +585 -0
- package/src/{ethereum-api.ts → ethereum-api.js} +1 -1
- package/src/examples/auto-stake-it-tap-kit.d.ts +4 -3
- package/src/examples/auto-stake-it-tap-kit.d.ts.map +1 -1
- package/src/examples/auto-stake-it-tap-kit.js +3 -4
- package/src/examples/auto-stake-it.contract.d.ts +6 -4
- package/src/examples/auto-stake-it.contract.d.ts.map +1 -1
- package/src/examples/auto-stake-it.contract.js +3 -1
- package/src/examples/auto-stake-it.flows.d.ts +2 -1
- package/src/examples/auto-stake-it.flows.d.ts.map +1 -1
- package/src/examples/auto-stake-it.flows.js +1 -0
- package/src/examples/axelar-gmp-account-kit.d.ts +6 -4
- package/src/examples/axelar-gmp-account-kit.d.ts.map +1 -1
- package/src/examples/axelar-gmp-account-kit.js +4 -2
- package/src/examples/axelar-gmp.contract.d.ts +8 -8
- package/src/examples/axelar-gmp.contract.d.ts.map +1 -1
- package/src/examples/axelar-gmp.contract.js +2 -2
- package/src/examples/axelar-gmp.flows.d.ts +1 -1
- package/src/examples/basic-flows.contract.d.ts +7 -5
- package/src/examples/basic-flows.contract.d.ts.map +1 -1
- package/src/examples/basic-flows.contract.js +3 -1
- package/src/examples/basic-flows.flows.d.ts +2 -1
- package/src/examples/basic-flows.flows.d.ts.map +1 -1
- package/src/examples/basic-flows.flows.js +1 -0
- package/src/examples/send-anywhere.contract.d.ts +12 -6
- package/src/examples/send-anywhere.contract.d.ts.map +1 -1
- package/src/examples/send-anywhere.contract.js +4 -1
- package/src/examples/send-anywhere.flows.d.ts +3 -2
- package/src/examples/send-anywhere.flows.d.ts.map +1 -1
- package/src/examples/send-anywhere.flows.js +3 -6
- package/src/examples/stake-bld.contract.d.ts +206 -25
- package/src/examples/stake-bld.contract.d.ts.map +1 -1
- package/src/examples/stake-bld.contract.js +19 -4
- package/src/examples/stake-ica.contract.d.ts +434 -71
- package/src/examples/stake-ica.contract.d.ts.map +1 -1
- package/src/examples/stake-ica.contract.js +28 -6
- package/src/examples/staking-combinations.contract.d.ts +4 -2
- package/src/examples/staking-combinations.contract.d.ts.map +1 -1
- package/src/examples/staking-combinations.contract.js +5 -3
- package/src/examples/staking-combinations.flows.d.ts +3 -2
- package/src/examples/staking-combinations.flows.d.ts.map +1 -1
- package/src/examples/staking-combinations.flows.js +7 -6
- package/src/examples/swap-anything.contract.d.ts +14 -7
- package/src/examples/swap-anything.contract.d.ts.map +1 -1
- package/src/examples/swap-anything.contract.js +12 -8
- package/src/examples/swap.contract.d.ts +18 -6
- package/src/examples/swap.contract.d.ts.map +1 -1
- package/src/examples/swap.contract.js +9 -3
- package/src/examples/swap.flows.d.ts +2 -0
- package/src/examples/swap.flows.d.ts.map +1 -1
- package/src/examples/swap.flows.js +2 -0
- package/src/examples/unbond.contract.d.ts +7 -4
- package/src/examples/unbond.contract.d.ts.map +1 -1
- package/src/examples/unbond.contract.js +6 -3
- package/src/exos/chain-hub-admin.d.ts +1 -19
- package/src/exos/chain-hub-admin.d.ts.map +1 -1
- package/src/exos/chain-hub-admin.js +1 -1
- package/src/exos/chain-hub.d.ts +4 -2
- package/src/exos/chain-hub.d.ts.map +1 -1
- package/src/exos/chain-hub.js +2 -1
- package/src/exos/combine-invitation-makers.d.ts +2 -1
- package/src/exos/combine-invitation-makers.d.ts.map +1 -1
- package/src/exos/combine-invitation-makers.js +2 -1
- package/src/exos/cosmos-orchestration-account.d.ts +615 -98
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
- package/src/exos/cosmos-orchestration-account.js +695 -306
- package/src/exos/exo-interfaces.js +35 -0
- package/src/exos/ibc-packet.d.ts +11 -9
- package/src/exos/ibc-packet.d.ts.map +1 -1
- package/src/exos/ibc-packet.js +33 -8
- package/src/exos/ica-account-kit.d.ts +4 -9
- package/src/exos/ica-account-kit.d.ts.map +1 -1
- package/src/exos/ica-account-kit.js +10 -7
- package/src/exos/icq-connection-kit.d.ts +1 -1
- package/src/exos/local-chain-facade.d.ts +1542 -5
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-chain-facade.js +4 -2
- package/src/exos/local-orchestration-account.d.ts +201 -56
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +260 -51
- package/src/exos/orchestrator.d.ts +35813 -73
- package/src/exos/orchestrator.d.ts.map +1 -1
- package/src/exos/orchestrator.js +7 -10
- package/src/exos/packet-tools.d.ts +19 -8
- package/src/exos/packet-tools.d.ts.map +1 -1
- package/src/exos/packet-tools.js +92 -9
- package/src/exos/portfolio-holder-kit.d.ts +90 -2
- package/src/exos/portfolio-holder-kit.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.d.ts +1499 -1
- package/src/exos/remote-chain-facade.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.js +8 -3
- package/src/facade.d.ts +1 -0
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +4 -6
- package/src/fixtures/query-flows.contract.d.ts +8 -6
- package/src/fixtures/query-flows.contract.d.ts.map +1 -1
- package/src/fixtures/query-flows.contract.js +3 -1
- package/src/fixtures/query-flows.flows.d.ts +1 -0
- package/src/fixtures/query-flows.flows.d.ts.map +1 -1
- package/src/fixtures/query-flows.flows.js +1 -0
- package/src/orchestration-api.d.ts +46 -16
- package/src/orchestration-api.d.ts.map +1 -1
- package/src/orchestration-api.js +410 -0
- package/src/proposals/init-chain-info.js +10 -2
- package/src/proposals/orchestration-proposal.js +3 -0
- package/src/proposals/revise-chain-info.js +4 -1
- package/src/proposals/start-auto-stake-it.js +1 -0
- package/src/proposals/start-axelar-gmp.js +2 -2
- package/src/proposals/start-basic-flows.js +5 -0
- package/src/proposals/start-send-anywhere.js +4 -2
- package/src/proposals/start-stakeAtom.js +5 -4
- package/src/proposals/start-stakeBld.js +8 -6
- package/src/proposals/start-stakeOsmo.js +5 -4
- package/src/proposals/start-swap-anything.js +4 -2
- package/src/stubs/{viem-abi.d.ts → viem-typedData.js} +10 -4
- package/src/typeGuards.d.ts +38 -5
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +92 -22
- package/src/types.d.ts +1 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.js +27 -0
- package/src/utils/abitype.d.ts +6 -0
- package/src/utils/abitype.d.ts.map +1 -0
- package/src/utils/abitype.js +13 -0
- package/src/utils/address.d.ts +3 -1
- package/src/utils/address.d.ts.map +1 -1
- package/src/utils/address.js +24 -2
- package/src/utils/agd-lib.d.ts +1 -51
- package/src/utils/agd-lib.d.ts.map +1 -1
- package/src/utils/agd-lib.js +1 -1
- package/src/utils/amounts.d.ts +1 -0
- package/src/utils/amounts.d.ts.map +1 -1
- package/src/utils/amounts.js +1 -0
- package/src/utils/asset.d.ts +1 -0
- package/src/utils/asset.d.ts.map +1 -1
- package/src/utils/asset.js +1 -0
- package/src/utils/chain-hub-helper.d.ts +1 -0
- package/src/utils/chain-hub-helper.d.ts.map +1 -1
- package/src/utils/chain-hub-helper.js +1 -0
- package/src/utils/codecs.d.ts +145 -0
- package/src/utils/codecs.d.ts.map +1 -0
- package/src/utils/codecs.js +206 -0
- package/src/utils/cosmos.d.ts +5 -4
- package/src/utils/cosmos.d.ts.map +1 -1
- package/src/utils/cosmos.js +29 -9
- package/src/utils/exo-helpers.d.ts +156 -0
- package/src/utils/exo-helpers.d.ts.map +1 -0
- package/src/utils/exo-helpers.js +241 -0
- package/src/utils/gmp.d.ts +2 -2
- package/src/utils/gmp.d.ts.map +1 -1
- package/src/utils/gmp.js +31 -15
- package/src/utils/orchestrationAccount.d.ts +79 -0
- package/src/utils/orchestrationAccount.d.ts.map +1 -1
- package/src/utils/orchestrationAccount.js +210 -6
- package/src/utils/packet.d.ts.map +1 -1
- package/src/utils/packet.js +5 -0
- package/src/utils/permit2/signatureTransfer.d.ts +221 -0
- package/src/utils/permit2/signatureTransfer.d.ts.map +1 -0
- package/src/utils/permit2/signatureTransfer.js +265 -0
- package/src/utils/permit2/signatureTransferHelpers.d.ts +334 -0
- package/src/utils/permit2/signatureTransferHelpers.d.ts.map +1 -0
- package/src/utils/permit2/signatureTransferHelpers.js +270 -0
- package/src/utils/permit2.d.ts +11 -0
- package/src/utils/permit2.d.ts.map +1 -0
- package/src/utils/permit2.js +11 -0
- package/src/utils/progress.d.ts +41 -0
- package/src/utils/progress.d.ts.map +1 -0
- package/src/utils/progress.js +180 -0
- package/src/utils/start-helper.d.ts +28 -10
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +30 -7
- package/src/utils/time.d.ts +2 -2
- package/src/utils/time.d.ts.map +1 -1
- package/src/utils/time.js +1 -1
- package/src/utils/viem-utils/hashTypedData.d.ts +21 -0
- package/src/utils/viem-utils/hashTypedData.d.ts.map +1 -0
- package/src/utils/viem-utils/hashTypedData.js +61 -0
- package/src/utils/viem-utils/types.d.ts +6 -0
- package/src/utils/viem-utils/types.d.ts.map +1 -0
- package/src/utils/viem-utils/types.js +18 -0
- package/src/utils/viem.d.ts +11 -0
- package/src/utils/viem.d.ts.map +1 -0
- package/src/utils/viem.js +11 -0
- package/src/utils/zcf-tools.d.ts +15 -1
- package/src/utils/zcf-tools.d.ts.map +1 -1
- package/src/utils/zcf-tools.js +19 -3
- package/src/utils/zoe-tools.d.ts +5 -2
- package/src/utils/zoe-tools.d.ts.map +1 -1
- package/src/utils/zoe-tools.js +8 -2
- package/src/vat-orchestration.d.ts +5 -3
- package/src/vat-orchestration.d.ts.map +1 -1
- package/src/vat-orchestration.js +4 -3
- package/src/vendor/viem/{_esm-YOAV66U4.js → _esm-OKAICHVC.js} +2 -2
- package/src/vendor/viem/{ccip-AAQDZF3N.js → ccip-34BSSMV5.js} +1 -2
- package/src/vendor/viem/{chunk-4EF4K2MH.js → chunk-GCI53Z2G.js} +35 -1
- package/src/vendor/viem/chunk-ZKSIP2AM.js +326 -0
- package/src/vendor/viem/viem-abi.js +2 -2
- package/src/vendor/viem/viem-typedData.d.ts +19 -0
- package/src/vendor/viem/viem-typedData.js +59 -0
- package/tools/contract-tests.d.ts +34 -19
- package/tools/contract-tests.d.ts.map +1 -1
- package/tools/contract-tests.ts +15 -3
- package/tools/ibc-mock-fixtures.d.ts +49 -0
- package/tools/ibc-mock-fixtures.d.ts.map +1 -0
- package/tools/ibc-mock-fixtures.ts +161 -0
- package/tools/ibc-mocks.d.ts +2 -3
- package/tools/ibc-mocks.d.ts.map +1 -1
- package/tools/ibc-mocks.ts +2 -1
- package/tools/make-test-address.d.ts +1 -1
- package/tools/make-test-address.d.ts.map +1 -1
- package/tools/make-test-address.js +1 -2
- package/tools/network-fakes.d.ts +142 -0
- package/tools/network-fakes.d.ts.map +1 -0
- package/tools/network-fakes.ts +388 -0
- package/tsup.config.ts +3 -1
- package/src/cosmos-api.ts +0 -469
- package/src/exos/exo-interfaces.ts +0 -35
- package/src/orchestration-api.ts +0 -365
- package/src/stubs/viem-abi.d.ts.map +0 -1
- package/src/types.ts +0 -26
- package/src/vendor/viem/chunk-XN4LUOIH.js +0 -253
- package/src/vendor/viem/secp256k1-WHBDSQB2.js +0 -1914
- /package/src/stubs/{viem-abi.ts → viem-abi.js} +0 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Signature transfer permit2 types and utilities
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* Copyright (c) 2021 Uniswap Lab
|
|
6
|
+
* Copied and adapted from https://github.com/Uniswap/sdks/blob/de28419fcae6e6ba6f88e4a4ae46b2fc9d226cd6/sdks/permit2-sdk/src/signatureTransfer.ts
|
|
7
|
+
*
|
|
8
|
+
* The modifications made are to generalize the witness type to allow defining the field name,
|
|
9
|
+
* and use viem types instead of ethers types.
|
|
10
|
+
*
|
|
11
|
+
* Some stylistic changes have also been made to conform to our code style.
|
|
12
|
+
*/
|
|
13
|
+
import type { TypedDataToPrimitiveTypes } from 'abitype';
|
|
14
|
+
import type { Address, TypedData, TypedDataDefinition } from 'viem';
|
|
15
|
+
import type { TypedDataParameter } from '../abitype.js';
|
|
16
|
+
interface WitnessDefinition<T extends TypedData = TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>> {
|
|
17
|
+
witnessField: TD;
|
|
18
|
+
witnessTypes: T;
|
|
19
|
+
}
|
|
20
|
+
export interface Witness<T extends TypedData = TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>> extends WitnessDefinition<T, TD> {
|
|
21
|
+
witness: TypedDataToPrimitiveTypes<T>[TD['type']];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Helper to help caller check that the `data` matches the inferred witness types
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-4.html#the-noinfer-utility-type}
|
|
27
|
+
*/
|
|
28
|
+
export declare function makeWitness<T extends TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>>>(data: NoInfer<TypedDataToPrimitiveTypes<T>[TD['type']]>, types: T, typeParam: TD): Witness<T, TD>;
|
|
29
|
+
export type TokenPermissions = {
|
|
30
|
+
token: Address;
|
|
31
|
+
amount: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type PermitTransferFrom = {
|
|
34
|
+
permitted: TokenPermissions;
|
|
35
|
+
spender: Address;
|
|
36
|
+
nonce: bigint;
|
|
37
|
+
deadline: bigint;
|
|
38
|
+
};
|
|
39
|
+
export type PermitBatchTransferFrom = {
|
|
40
|
+
permitted: readonly TokenPermissions[];
|
|
41
|
+
spender: Address;
|
|
42
|
+
nonce: bigint;
|
|
43
|
+
deadline: bigint;
|
|
44
|
+
};
|
|
45
|
+
export declare const PermitTransferFromTypeParams: [{
|
|
46
|
+
readonly name: "permitted";
|
|
47
|
+
readonly type: "TokenPermissions";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "spender";
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "nonce";
|
|
53
|
+
readonly type: "uint256";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "deadline";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
}];
|
|
58
|
+
export declare const PermitBatchTransferFromTypeParams: [{
|
|
59
|
+
readonly name: "permitted";
|
|
60
|
+
readonly type: "TokenPermissions[]";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "spender";
|
|
63
|
+
readonly type: "address";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "nonce";
|
|
66
|
+
readonly type: "uint256";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "deadline";
|
|
69
|
+
readonly type: "uint256";
|
|
70
|
+
}];
|
|
71
|
+
export declare const PermitTransferFromTypes: {
|
|
72
|
+
readonly EIP712Domain: [{
|
|
73
|
+
readonly name: "name";
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "chainId";
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "verifyingContract";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}];
|
|
82
|
+
readonly PermitTransferFrom: [{
|
|
83
|
+
readonly name: "permitted";
|
|
84
|
+
readonly type: "TokenPermissions";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "spender";
|
|
87
|
+
readonly type: "address";
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "nonce";
|
|
90
|
+
readonly type: "uint256";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "deadline";
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
}];
|
|
95
|
+
readonly TokenPermissions: [{
|
|
96
|
+
readonly name: "token";
|
|
97
|
+
readonly type: "address";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "amount";
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
}];
|
|
102
|
+
};
|
|
103
|
+
export declare const PermitBatchTransferFromTypes: {
|
|
104
|
+
readonly EIP712Domain: [{
|
|
105
|
+
readonly name: "name";
|
|
106
|
+
readonly type: "string";
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "chainId";
|
|
109
|
+
readonly type: "uint256";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "verifyingContract";
|
|
112
|
+
readonly type: "address";
|
|
113
|
+
}];
|
|
114
|
+
readonly PermitBatchTransferFrom: [{
|
|
115
|
+
readonly name: "permitted";
|
|
116
|
+
readonly type: "TokenPermissions[]";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "spender";
|
|
119
|
+
readonly type: "address";
|
|
120
|
+
}, {
|
|
121
|
+
readonly name: "nonce";
|
|
122
|
+
readonly type: "uint256";
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "deadline";
|
|
125
|
+
readonly type: "uint256";
|
|
126
|
+
}];
|
|
127
|
+
readonly TokenPermissions: [{
|
|
128
|
+
readonly name: "token";
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "amount";
|
|
132
|
+
readonly type: "uint256";
|
|
133
|
+
}];
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Generate an EIP-712 `types` record for a single-token
|
|
137
|
+
* `permitWitnessTransferFrom` call.
|
|
138
|
+
*/
|
|
139
|
+
export declare function permitWitnessTransferFromTypes<T extends TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>>(witness: WitnessDefinition<T, TD>): {
|
|
140
|
+
readonly EIP712Domain: [{
|
|
141
|
+
readonly name: "name";
|
|
142
|
+
readonly type: "string";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "chainId";
|
|
145
|
+
readonly type: "uint256";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "verifyingContract";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}];
|
|
150
|
+
readonly PermitWitnessTransferFrom: readonly [{
|
|
151
|
+
readonly name: "permitted";
|
|
152
|
+
readonly type: "TokenPermissions";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "spender";
|
|
155
|
+
readonly type: "address";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "nonce";
|
|
158
|
+
readonly type: "uint256";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "deadline";
|
|
161
|
+
readonly type: "uint256";
|
|
162
|
+
}, TD];
|
|
163
|
+
readonly TokenPermissions: [{
|
|
164
|
+
readonly name: "token";
|
|
165
|
+
readonly type: "address";
|
|
166
|
+
}, {
|
|
167
|
+
readonly name: "amount";
|
|
168
|
+
readonly type: "uint256";
|
|
169
|
+
}];
|
|
170
|
+
} & T;
|
|
171
|
+
/**
|
|
172
|
+
* Generate an EIP-712 `types` record for a multi-token
|
|
173
|
+
* `permitWitnessTransferFrom` call.
|
|
174
|
+
*/
|
|
175
|
+
export declare function permitBatchWitnessTransferFromTypes<T extends TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>>(witness: WitnessDefinition<T, TD>): {
|
|
176
|
+
readonly EIP712Domain: [{
|
|
177
|
+
readonly name: "name";
|
|
178
|
+
readonly type: "string";
|
|
179
|
+
}, {
|
|
180
|
+
readonly name: "chainId";
|
|
181
|
+
readonly type: "uint256";
|
|
182
|
+
}, {
|
|
183
|
+
readonly name: "verifyingContract";
|
|
184
|
+
readonly type: "address";
|
|
185
|
+
}];
|
|
186
|
+
readonly PermitBatchWitnessTransferFrom: readonly [{
|
|
187
|
+
readonly name: "permitted";
|
|
188
|
+
readonly type: "TokenPermissions[]";
|
|
189
|
+
}, {
|
|
190
|
+
readonly name: "spender";
|
|
191
|
+
readonly type: "address";
|
|
192
|
+
}, {
|
|
193
|
+
readonly name: "nonce";
|
|
194
|
+
readonly type: "uint256";
|
|
195
|
+
}, {
|
|
196
|
+
readonly name: "deadline";
|
|
197
|
+
readonly type: "uint256";
|
|
198
|
+
}, TD];
|
|
199
|
+
readonly TokenPermissions: [{
|
|
200
|
+
readonly name: "token";
|
|
201
|
+
readonly type: "address";
|
|
202
|
+
}, {
|
|
203
|
+
readonly name: "amount";
|
|
204
|
+
readonly type: "uint256";
|
|
205
|
+
}];
|
|
206
|
+
} & T;
|
|
207
|
+
export type PermitWitnessTransferFrom<T extends Record<string, unknown>, TN extends string = 'witness'> = PermitTransferFrom & {
|
|
208
|
+
[key in TN]: T;
|
|
209
|
+
};
|
|
210
|
+
export type PermitBatchWitnessTransferFrom<T extends Record<string, unknown>, TN extends string = 'witness'> = PermitBatchTransferFrom & {
|
|
211
|
+
[key in TN]: T;
|
|
212
|
+
};
|
|
213
|
+
export declare function permit2Domain(permit2Address: Address, chainId: number | bigint): {
|
|
214
|
+
readonly name: "Permit2";
|
|
215
|
+
readonly chainId: number | bigint;
|
|
216
|
+
readonly verifyingContract: `0x${string}`;
|
|
217
|
+
};
|
|
218
|
+
export declare function getPermitWitnessTransferFromData<T extends TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>>(permit: PermitTransferFrom, permit2Address: Address, chainId: number | bigint, witness: Witness<T, TD>): TypedDataDefinition<ReturnType<typeof permitWitnessTransferFromTypes<T, TD>>, 'PermitWitnessTransferFrom', 'PermitWitnessTransferFrom'>;
|
|
219
|
+
export declare function getPermitBatchWitnessTransferFromData<T extends TypedData, TD extends TypedDataParameter<string, Extract<keyof T, string>> = TypedDataParameter<'witness', Extract<keyof T, string>>>(permit: PermitBatchTransferFrom, permit2Address: Address, chainId: number | bigint, witness: Witness<T, TD>): TypedDataDefinition<ReturnType<typeof permitBatchWitnessTransferFromTypes<T, TD>>, 'PermitBatchWitnessTransferFrom', 'PermitBatchWitnessTransferFrom'>;
|
|
220
|
+
export {};
|
|
221
|
+
//# sourceMappingURL=signatureTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTransfer.d.ts","sourceRoot":"","sources":["signatureTransfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,mBAAmB,EAEpB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKxD,UAAU,iBAAiB,CACzB,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,EAAE,SAAS,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7D,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAEzD,YAAY,EAAE,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;CACjB;AAED,MAAM,WAAW,OAAO,CACtB,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,EAAE,SAAS,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7D,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CACzD,SAAQ,iBAAiB,CAAC,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,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M,GAAG,MAAM,EACxB,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,GACtB,mBAAmB,CACpB,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EACxD,2BAA2B,EAC3B,2BAA2B,CAC5B,CAoBA;AAED,wBAAgB,qCAAqC,CACnD,CAAC,SAAS,SAAS,EACnB,EAAE,SAAS,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7D,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,EAEzD,MAAM,EAAE,uBAAuB,EAC/B,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,GACtB,mBAAmB,CACpB,UAAU,CAAC,OAAO,mCAAmC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAC7D,gCAAgC,EAChC,gCAAgC,CACjC,CAoBA"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Signature transfer permit2 types and utilities
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* Copyright (c) 2021 Uniswap Lab
|
|
6
|
+
* Copied and adapted from https://github.com/Uniswap/sdks/blob/de28419fcae6e6ba6f88e4a4ae46b2fc9d226cd6/sdks/permit2-sdk/src/signatureTransfer.ts
|
|
7
|
+
*
|
|
8
|
+
* The modifications made are to generalize the witness type to allow defining the field name,
|
|
9
|
+
* and use viem types instead of ethers types.
|
|
10
|
+
*
|
|
11
|
+
* Some stylistic changes have also been made to conform to our code style.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const PERMIT2_DOMAIN_NAME = 'Permit2';
|
|
24
|
+
|
|
25
|
+
// TODO: disallow witness type field being another Permit field name
|
|
26
|
+
;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Helper to help caller check that the `data` matches the inferred witness types
|
|
45
|
+
*
|
|
46
|
+
* @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-4.html#the-noinfer-utility-type}
|
|
47
|
+
*/
|
|
48
|
+
export function makeWitness(
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
data ,
|
|
53
|
+
types ,
|
|
54
|
+
typeParam ,
|
|
55
|
+
) {
|
|
56
|
+
return {
|
|
57
|
+
witness: data,
|
|
58
|
+
witnessTypes: types,
|
|
59
|
+
witnessField: typeParam,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
const Permit2DomainTypeParams = [
|
|
83
|
+
{ name: 'name', type: 'string' },
|
|
84
|
+
{ name: 'chainId', type: 'uint256' },
|
|
85
|
+
{ name: 'verifyingContract', type: 'address' },
|
|
86
|
+
] ;
|
|
87
|
+
|
|
88
|
+
export const PermitTransferFromTypeParams = [
|
|
89
|
+
{ name: 'permitted', type: 'TokenPermissions' },
|
|
90
|
+
{ name: 'spender', type: 'address' },
|
|
91
|
+
{ name: 'nonce', type: 'uint256' },
|
|
92
|
+
{ name: 'deadline', type: 'uint256' },
|
|
93
|
+
] ;
|
|
94
|
+
|
|
95
|
+
export const PermitBatchTransferFromTypeParams = [
|
|
96
|
+
{ name: 'permitted', type: 'TokenPermissions[]' },
|
|
97
|
+
{ name: 'spender', type: 'address' },
|
|
98
|
+
{ name: 'nonce', type: 'uint256' },
|
|
99
|
+
{ name: 'deadline', type: 'uint256' },
|
|
100
|
+
] ;
|
|
101
|
+
|
|
102
|
+
const TokenPermissionTypeParams = [
|
|
103
|
+
{ name: 'token', type: 'address' },
|
|
104
|
+
{ name: 'amount', type: 'uint256' },
|
|
105
|
+
] ;
|
|
106
|
+
|
|
107
|
+
export const PermitTransferFromTypes = {
|
|
108
|
+
EIP712Domain: Permit2DomainTypeParams,
|
|
109
|
+
PermitTransferFrom: PermitTransferFromTypeParams,
|
|
110
|
+
TokenPermissions: TokenPermissionTypeParams,
|
|
111
|
+
} ;
|
|
112
|
+
|
|
113
|
+
export const PermitBatchTransferFromTypes = {
|
|
114
|
+
EIP712Domain: Permit2DomainTypeParams,
|
|
115
|
+
PermitBatchTransferFrom: PermitBatchTransferFromTypeParams,
|
|
116
|
+
TokenPermissions: TokenPermissionTypeParams,
|
|
117
|
+
} ;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Generate an EIP-712 `types` record for a single-token
|
|
121
|
+
* `permitWitnessTransferFrom` call.
|
|
122
|
+
*/
|
|
123
|
+
export function permitWitnessTransferFromTypes(
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
witness ) {
|
|
128
|
+
return {
|
|
129
|
+
EIP712Domain: Permit2DomainTypeParams,
|
|
130
|
+
PermitWitnessTransferFrom: [
|
|
131
|
+
...PermitTransferFromTypeParams,
|
|
132
|
+
// `witness` is required by static typing, but when it is undefined at
|
|
133
|
+
// runtime, this emits types in which PermitWitnessTransferFrom is
|
|
134
|
+
// truncated just before where a witness field belongs.
|
|
135
|
+
// Doing so simplifies the function returned by
|
|
136
|
+
// {@link makeWitnessTypeStringExtractor}, because the EIP-712 string
|
|
137
|
+
// encoding of that type has its first `)` at that position (i.e.,
|
|
138
|
+
// `PermitWitnessTransferFrom(TokenPermissions permitted,...,uint256 deadline)TokenPermissions(...)`).
|
|
139
|
+
...((witness ? [witness.witnessField] : []) ),
|
|
140
|
+
],
|
|
141
|
+
TokenPermissions: TokenPermissionTypeParams,
|
|
142
|
+
...witness?.witnessTypes,
|
|
143
|
+
} ;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Generate an EIP-712 `types` record for a multi-token
|
|
148
|
+
* `permitWitnessTransferFrom` call.
|
|
149
|
+
*/
|
|
150
|
+
export function permitBatchWitnessTransferFromTypes(
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
witness ) {
|
|
155
|
+
return {
|
|
156
|
+
EIP712Domain: Permit2DomainTypeParams,
|
|
157
|
+
PermitBatchWitnessTransferFrom: [
|
|
158
|
+
...PermitBatchTransferFromTypeParams,
|
|
159
|
+
// `witness` is required by static typing, but when it is undefined at
|
|
160
|
+
// runtime, this emits types in which PermitBatchWitnessTransferFrom is
|
|
161
|
+
// truncated just before where a witness field belongs.
|
|
162
|
+
// Doing so simplifies the function returned by
|
|
163
|
+
// {@link makeWitnessTypeStringExtractor}, because the EIP-712 string
|
|
164
|
+
// encoding of that type has its first `)` at that position (i.e.,
|
|
165
|
+
// `PermitBatchWitnessTransferFrom(TokenPermissions[] permitted,...,uint256 deadline)TokenPermissions(...)`).
|
|
166
|
+
...((witness ? [witness.witnessField] : []) ),
|
|
167
|
+
],
|
|
168
|
+
TokenPermissions: TokenPermissionTypeParams,
|
|
169
|
+
...witness?.witnessTypes,
|
|
170
|
+
} ;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
;
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
;
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
export function permit2Domain(
|
|
184
|
+
permit2Address ,
|
|
185
|
+
chainId ,
|
|
186
|
+
) {
|
|
187
|
+
return {
|
|
188
|
+
name: PERMIT2_DOMAIN_NAME,
|
|
189
|
+
chainId,
|
|
190
|
+
verifyingContract: permit2Address,
|
|
191
|
+
} ;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// XXX: restore permit to be either PermitTransferFrom or PermitBatchTransferFrom
|
|
195
|
+
// and remove duplication between the two functions below
|
|
196
|
+
// Original method was `SignatureTransfer.getPermitData`
|
|
197
|
+
export function getPermitWitnessTransferFromData(
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
permit ,
|
|
203
|
+
permit2Address ,
|
|
204
|
+
chainId ,
|
|
205
|
+
witness ,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
{
|
|
211
|
+
// type MessageType = TypedDataToPrimitiveTypes<
|
|
212
|
+
// ReturnType<typeof permitWitnessTransferFromTypes<T, TD>>
|
|
213
|
+
// >['PermitWitnessTransferFrom'];
|
|
214
|
+
|
|
215
|
+
const domain = permit2Domain(permit2Address, chainId);
|
|
216
|
+
|
|
217
|
+
const types = permitWitnessTransferFromTypes(witness);
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
// @ts-expect-error some generic type inference issue
|
|
221
|
+
domain,
|
|
222
|
+
types,
|
|
223
|
+
primaryType: 'PermitWitnessTransferFrom',
|
|
224
|
+
// @ts-expect-error some generic type inference issue
|
|
225
|
+
message: {
|
|
226
|
+
...permit,
|
|
227
|
+
[witness.witnessField.name]: witness.witness,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function getPermitBatchWitnessTransferFromData(
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
permit ,
|
|
238
|
+
permit2Address ,
|
|
239
|
+
chainId ,
|
|
240
|
+
witness ,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
{
|
|
246
|
+
// type MessageType = TypedDataToPrimitiveTypes<
|
|
247
|
+
// ReturnType<typeof permitBatchWitnessTransferFromTypes<T, TD>>
|
|
248
|
+
// >['PermitBatchWitnessTransferFrom'];
|
|
249
|
+
|
|
250
|
+
const domain = permit2Domain(permit2Address, chainId);
|
|
251
|
+
|
|
252
|
+
const types = permitBatchWitnessTransferFromTypes(witness);
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
// @ts-expect-error some generic type inference issue
|
|
256
|
+
domain,
|
|
257
|
+
types,
|
|
258
|
+
primaryType: 'PermitBatchWitnessTransferFrom',
|
|
259
|
+
// @ts-expect-error some generic type inference issue
|
|
260
|
+
message: {
|
|
261
|
+
...permit,
|
|
262
|
+
[witness.witnessField.name]: witness.witness,
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|