@unionlabs/payments 0.3.0 → 0.3.1
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/ChainRegistry/package.json +6 -0
- package/README.md +283 -1
- package/dist/cjs/ChainRegistry.js +24 -0
- package/dist/cjs/ChainRegistry.js.map +1 -0
- package/dist/cjs/Payment.js +10 -8
- package/dist/cjs/Payment.js.map +1 -1
- package/dist/cjs/WalletClient.js.map +1 -1
- package/dist/cjs/constants/ibc-core-registry.js +5 -7
- package/dist/cjs/constants/ibc-core-registry.js.map +1 -1
- package/dist/cjs/constants/z-asset-registry.js +9 -7
- package/dist/cjs/constants/z-asset-registry.js.map +1 -1
- package/dist/cjs/internal/evmWalletClient.js +24 -69
- package/dist/cjs/internal/evmWalletClient.js.map +1 -1
- package/dist/dts/ChainRegistry.d.ts +6 -0
- package/dist/dts/ChainRegistry.d.ts.map +1 -0
- package/dist/dts/Payment.d.ts +7 -8
- package/dist/dts/Payment.d.ts.map +1 -1
- package/dist/dts/PublicClient.d.ts +4 -4
- package/dist/dts/PublicClient.d.ts.map +1 -1
- package/dist/dts/WalletClient.d.ts +1 -3
- package/dist/dts/WalletClient.d.ts.map +1 -1
- package/dist/dts/constants/ibc-core-registry.d.ts +4 -4
- package/dist/dts/constants/ibc-core-registry.d.ts.map +1 -1
- package/dist/dts/constants/z-asset-registry.d.ts +4 -4
- package/dist/dts/constants/z-asset-registry.d.ts.map +1 -1
- package/dist/dts/promises/Payment.d.ts +3 -3
- package/dist/esm/ChainRegistry.js +16 -0
- package/dist/esm/ChainRegistry.js.map +1 -0
- package/dist/esm/Payment.js +10 -8
- package/dist/esm/Payment.js.map +1 -1
- package/dist/esm/Schema.js +4 -8
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/WalletClient.js.map +1 -1
- package/dist/esm/constants/ibc-core-registry.js +3 -4
- package/dist/esm/constants/ibc-core-registry.js.map +1 -1
- package/dist/esm/constants/z-asset-registry.js +7 -4
- package/dist/esm/constants/z-asset-registry.js.map +1 -1
- package/dist/esm/internal/evmWalletClient.js +23 -67
- package/dist/esm/internal/evmWalletClient.js.map +1 -1
- package/package.json +9 -1
- package/src/ChainRegistry.ts +27 -0
- package/src/Payment.ts +33 -25
- package/src/PublicClient.ts +4 -4
- package/src/WalletClient.ts +1 -3
- package/src/constants/ibc-core-registry.ts +11 -7
- package/src/constants/z-asset-registry.ts +10 -7
- package/src/internal/evmWalletClient.ts +29 -84
- package/unionlabs-payments-0.3.1.tgz +0 -0
- package/src/tsdoc-metadata.json +0 -11
- package/unionlabs-payments-0.3.0.tgz +0 -0
- /package/{constants → Constants}/ibc-core-registry/package.json +0 -0
- /package/{constants → Constants}/services/package.json +0 -0
- /package/{constants → Constants}/z-asset-registry/package.json +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Effect, Option as O, pipe, Record as R } from "effect";
|
|
2
|
+
import * as Domain from "./Domain.js";
|
|
3
|
+
import * as Error from "./Error.js";
|
|
4
|
+
|
|
5
|
+
export const UniversalChainIdMap: Record<Domain.UniversalChainId, bigint> = {
|
|
6
|
+
[Domain.UniversalChainId.make("base.8453")]: 8453n,
|
|
7
|
+
[Domain.UniversalChainId.make("ethereum.1")]: 1n,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getOrError: (
|
|
11
|
+
ucid: Domain.UniversalChainId,
|
|
12
|
+
) => Effect.Effect<bigint, Error.SdkError, never> = (ucid) =>
|
|
13
|
+
pipe(
|
|
14
|
+
UniversalChainIdMap,
|
|
15
|
+
R.get(ucid),
|
|
16
|
+
O.match({
|
|
17
|
+
onNone: () =>
|
|
18
|
+
Effect.fail(
|
|
19
|
+
new Error.SystemError({
|
|
20
|
+
method: "resolveUniversalChainId",
|
|
21
|
+
module: "EvmWalletClient",
|
|
22
|
+
reason: "InvalidData",
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
onSome: Effect.succeed,
|
|
26
|
+
}),
|
|
27
|
+
);
|
package/src/Payment.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
toHex,
|
|
17
17
|
} from "viem";
|
|
18
18
|
import type * as Attestor from "./Attestor.js";
|
|
19
|
+
import * as ChainRegistry from "./ChainRegistry.js";
|
|
19
20
|
import * as Constants from "./Constants.js";
|
|
20
21
|
import * as ZAssetRegistry from "./constants/z-asset-registry.js";
|
|
21
22
|
import * as Domain from "./Domain.js";
|
|
@@ -39,9 +40,8 @@ export interface DepositOptions {
|
|
|
39
40
|
readonly depositAddress: DepositAddress;
|
|
40
41
|
/** Amount to deposit (in underlying token's smallest unit) */
|
|
41
42
|
readonly amount: bigint;
|
|
42
|
-
readonly sourceChainId: bigint;
|
|
43
43
|
readonly srcErc20Address: Domain.Erc20Address;
|
|
44
|
-
readonly
|
|
44
|
+
readonly destinationChainId: Domain.UniversalChainId;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -72,23 +72,27 @@ export interface DepositAddress {
|
|
|
72
72
|
Domain.Erc20Address,
|
|
73
73
|
];
|
|
74
74
|
readonly zAssetAddress: Domain.ZAssetAddress;
|
|
75
|
-
readonly destinationChainId:
|
|
75
|
+
readonly destinationChainId: Domain.UniversalChainId;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export const getDepositAddress = Effect.fn("getDepositAddress")(
|
|
79
79
|
(options: {
|
|
80
80
|
paymentKey: Domain.PaymentKey;
|
|
81
81
|
beneficiaries: ReadonlyArray<Domain.Erc20Address>;
|
|
82
|
-
destinationChainId:
|
|
82
|
+
destinationChainId: Domain.UniversalChainId;
|
|
83
83
|
}) =>
|
|
84
84
|
Effect.gen(function* () {
|
|
85
85
|
const paddedBeneficiaries = yield* padBeneficiaries(
|
|
86
86
|
options.beneficiaries,
|
|
87
87
|
);
|
|
88
|
+
|
|
89
|
+
const _destinationChainId = yield* ChainRegistry.getOrError(
|
|
90
|
+
options.destinationChainId,
|
|
91
|
+
);
|
|
88
92
|
const unspendableAddress = pipe(
|
|
89
93
|
Poseidon2.computeUnspendableAddress(
|
|
90
94
|
options.paymentKey,
|
|
91
|
-
|
|
95
|
+
_destinationChainId,
|
|
92
96
|
paddedBeneficiaries,
|
|
93
97
|
),
|
|
94
98
|
Domain.Erc20Address,
|
|
@@ -96,6 +100,7 @@ export const getDepositAddress = Effect.fn("getDepositAddress")(
|
|
|
96
100
|
|
|
97
101
|
return {
|
|
98
102
|
beneficiaries: paddedBeneficiaries,
|
|
103
|
+
// TODO: unspendablae address
|
|
99
104
|
zAssetAddress: Domain.ZAssetAddress(unspendableAddress),
|
|
100
105
|
destinationChainId: options.destinationChainId,
|
|
101
106
|
};
|
|
@@ -132,26 +137,27 @@ const padBeneficiaries = Effect.fn("padBeneficiaries")(
|
|
|
132
137
|
|
|
133
138
|
export const getNullifier: (options: {
|
|
134
139
|
paymentKey: Domain.PaymentKey;
|
|
135
|
-
destinationChainId:
|
|
140
|
+
destinationChainId: Domain.UniversalChainId;
|
|
136
141
|
}) => Effect.Effect<Domain.Nullifier, Error.SdkError, never> = Effect.fn(
|
|
137
142
|
"getNullifier",
|
|
138
143
|
)((options) =>
|
|
139
144
|
pipe(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
options.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
ChainRegistry.getOrError(options.destinationChainId),
|
|
146
|
+
Effect.flatMap((chainId) =>
|
|
147
|
+
pipe(
|
|
148
|
+
Effect.try({
|
|
149
|
+
try: () => Poseidon2.computeNullifier(options.paymentKey, chainId),
|
|
150
|
+
catch: (cause) =>
|
|
151
|
+
new Error.SystemError({
|
|
152
|
+
method: "getNullifier",
|
|
153
|
+
module: "PaymentClient",
|
|
154
|
+
reason: "InvalidData",
|
|
155
|
+
cause,
|
|
156
|
+
}),
|
|
152
157
|
}),
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
Effect.map(Domain.Nullifier),
|
|
159
|
+
),
|
|
160
|
+
),
|
|
155
161
|
),
|
|
156
162
|
);
|
|
157
163
|
/**
|
|
@@ -260,7 +266,7 @@ export const generateProof: (options: {
|
|
|
260
266
|
selectedClientId: number;
|
|
261
267
|
nullifier: Domain.Nullifier;
|
|
262
268
|
depositAddress: DepositAddress;
|
|
263
|
-
srcChainId:
|
|
269
|
+
srcChainId: Domain.UniversalChainId;
|
|
264
270
|
srcErc20Address: Domain.Erc20Address;
|
|
265
271
|
dstErc20Address: Domain.Erc20Address;
|
|
266
272
|
}) => Effect.Effect<
|
|
@@ -404,9 +410,13 @@ export const generateProof: (options: {
|
|
|
404
410
|
blockNumber: selectedClient.height,
|
|
405
411
|
});
|
|
406
412
|
|
|
413
|
+
const dstChainId = yield* ChainRegistry.getOrError(
|
|
414
|
+
options.depositAddress.destinationChainId,
|
|
415
|
+
);
|
|
416
|
+
|
|
407
417
|
const witness: Prover.WitnessData = {
|
|
408
418
|
secret: options.paymentKey,
|
|
409
|
-
dstChainId
|
|
419
|
+
dstChainId,
|
|
410
420
|
beneficiaries: options.depositAddress.beneficiaries,
|
|
411
421
|
beneficiary: options.beneficiary,
|
|
412
422
|
redeemAmount: options.amount,
|
|
@@ -539,11 +549,9 @@ export const prepareDeposit = Effect.fn("deposit")((options: DepositOptions) =>
|
|
|
539
549
|
return yield* srcWalletClient.prepareDeposit({
|
|
540
550
|
amount: options.amount,
|
|
541
551
|
depositAddress: options.depositAddress.zAssetAddress,
|
|
542
|
-
sourceChainId: options.sourceChainId,
|
|
543
552
|
srcErc20Address: options.srcErc20Address,
|
|
544
553
|
beneficiaries: options.depositAddress.beneficiaries,
|
|
545
|
-
destinationChainId: options.
|
|
546
|
-
universalChainId: options.universalChainId,
|
|
554
|
+
destinationChainId: options.destinationChainId,
|
|
547
555
|
});
|
|
548
556
|
}),
|
|
549
557
|
);
|
package/src/PublicClient.ts
CHANGED
|
@@ -120,9 +120,9 @@ export namespace PublicClient {
|
|
|
120
120
|
*/
|
|
121
121
|
export interface ReadBalanceOptions {
|
|
122
122
|
readonly srcErc20Address: Domain.Erc20Address;
|
|
123
|
-
readonly srcChainId:
|
|
123
|
+
readonly srcChainId: Domain.UniversalChainId;
|
|
124
124
|
readonly dstErc20Address: Domain.Erc20Address;
|
|
125
|
-
readonly dstChainId:
|
|
125
|
+
readonly dstChainId: Domain.UniversalChainId;
|
|
126
126
|
readonly depositAddress: `0x${string}`;
|
|
127
127
|
readonly nullifier: Domain.Nullifier;
|
|
128
128
|
readonly clientId: number;
|
|
@@ -136,8 +136,8 @@ export namespace PublicClient {
|
|
|
136
136
|
export interface ReadBalanceAtHeightOptions {
|
|
137
137
|
readonly srcErc20Address: Domain.Erc20Address;
|
|
138
138
|
readonly dstErc20Address: Domain.Erc20Address;
|
|
139
|
-
readonly srcChainId:
|
|
140
|
-
readonly dstChainId:
|
|
139
|
+
readonly srcChainId: Domain.UniversalChainId;
|
|
140
|
+
readonly dstChainId: Domain.UniversalChainId;
|
|
141
141
|
readonly depositAddress: `0x${string}`;
|
|
142
142
|
readonly nullifier: Domain.Nullifier;
|
|
143
143
|
readonly height: bigint;
|
package/src/WalletClient.ts
CHANGED
|
@@ -157,12 +157,10 @@ export namespace WalletClient {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
export type Deposit = {
|
|
160
|
-
|
|
160
|
+
destinationChainId: Domain.UniversalChainId;
|
|
161
161
|
srcErc20Address: Domain.Erc20Address;
|
|
162
|
-
sourceChainId: bigint;
|
|
163
162
|
readonly beneficiaries: ReadonlyArray<Address>;
|
|
164
163
|
depositAddress: Domain.ZAssetAddress;
|
|
165
|
-
destinationChainId: bigint;
|
|
166
164
|
amount: bigint;
|
|
167
165
|
};
|
|
168
166
|
|
|
@@ -3,16 +3,20 @@ import * as Domain from "../Domain.js";
|
|
|
3
3
|
import * as Error from "../Error.js";
|
|
4
4
|
|
|
5
5
|
export const IBC_CORE_REGISTRY: {
|
|
6
|
-
[chainId:
|
|
6
|
+
[chainId: Domain.UniversalChainId]: Domain.IbcCoreAddress;
|
|
7
7
|
} = {
|
|
8
|
-
"8453": Domain.IbcCoreAddress(
|
|
8
|
+
[Domain.UniversalChainId.make("base.8453")]: Domain.IbcCoreAddress(
|
|
9
|
+
"0xee4ea8d358473f0fcebf0329feed95d56e8c04d7",
|
|
10
|
+
),
|
|
11
|
+
[Domain.UniversalChainId.make("ethereum.1")]: Domain.IbcCoreAddress(
|
|
12
|
+
"0xee4ea8d358473f0fcebf0329feed95d56e8c04d7",
|
|
13
|
+
),
|
|
9
14
|
} as const;
|
|
10
15
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
): Option.Option<Domain.IbcCoreAddress>
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
+
export const getIbcCoreAddress = (
|
|
17
|
+
ucid: Domain.UniversalChainId,
|
|
18
|
+
): Option.Option<Domain.IbcCoreAddress> =>
|
|
19
|
+
Option.fromNullable(IBC_CORE_REGISTRY[ucid]);
|
|
16
20
|
|
|
17
21
|
export const getIbcCoreAddressOrError = flow(
|
|
18
22
|
getIbcCoreAddress,
|
|
@@ -4,22 +4,25 @@ import * as Domain from "../Domain.js";
|
|
|
4
4
|
import * as Error from "../Error.js";
|
|
5
5
|
|
|
6
6
|
export const Z_ASSET_REGISTRY: {
|
|
7
|
-
[chainId:
|
|
7
|
+
[chainId: Domain.UniversalChainId]: {
|
|
8
8
|
[assetAddress: Erc20Address]: Domain.ZAssetAddress;
|
|
9
9
|
};
|
|
10
10
|
} = {
|
|
11
|
-
"8453": {
|
|
11
|
+
[Domain.UniversalChainId.make("base.8453")]: {
|
|
12
12
|
[Domain.Erc20Address("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")]:
|
|
13
13
|
Domain.ZAssetAddress("0xF0000101561619d8A61ABd045F47Af4f41Afe62D"),
|
|
14
14
|
},
|
|
15
|
+
[Domain.UniversalChainId.make("ethereum.1")]: {
|
|
16
|
+
[Domain.Erc20Address("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")]: // USDC on ethereum.1
|
|
17
|
+
Domain.ZAssetAddress("0xF0000101561619d8A61ABd045F47Af4f41Afe62D"),
|
|
18
|
+
},
|
|
15
19
|
} as const;
|
|
16
20
|
|
|
17
|
-
export
|
|
18
|
-
|
|
21
|
+
export const getZAsset = (
|
|
22
|
+
universalChainId: Domain.UniversalChainId,
|
|
19
23
|
assetAddress: Erc20Address,
|
|
20
|
-
): Option.Option<Domain.ZAssetAddress>
|
|
21
|
-
|
|
22
|
-
}
|
|
24
|
+
): Option.Option<Domain.ZAssetAddress> =>
|
|
25
|
+
Option.fromNullable(Z_ASSET_REGISTRY?.[universalChainId]?.[assetAddress]);
|
|
23
26
|
|
|
24
27
|
export const getZAssetOrError = flow(
|
|
25
28
|
getZAsset,
|
|
@@ -2,14 +2,11 @@ import * as A from "effect/Array";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import { pipe } from "effect/Function";
|
|
4
4
|
import * as Number from "effect/Number";
|
|
5
|
-
import * as O from "effect/Option";
|
|
6
5
|
import type * as P from "effect/Predicate";
|
|
7
|
-
import * as R from "effect/Record";
|
|
8
6
|
import * as Ref from "effect/Ref";
|
|
9
7
|
import type * as Scope from "effect/Scope";
|
|
10
8
|
import type * as Mipd from "mipd";
|
|
11
9
|
import type * as Viem from "viem";
|
|
12
|
-
import * as ViemChains from "viem/chains";
|
|
13
10
|
import * as Abi from "../Abi.js";
|
|
14
11
|
import * as ZAssetRegistry from "../constants/z-asset-registry.js";
|
|
15
12
|
import * as Domain from "../Domain.js";
|
|
@@ -18,30 +15,6 @@ import type * as EvmWalletClient from "../EvmWalletClient.js";
|
|
|
18
15
|
import * as Client from "../WalletClient.js";
|
|
19
16
|
import * as internalEvmPublicClient from "./evmPublicClient.js";
|
|
20
17
|
|
|
21
|
-
const UniversalChainIdMap: Record<Domain.UniversalChainId, Viem.Chain> = {
|
|
22
|
-
[Domain.UniversalChainId.make("base.8453")]: ViemChains.base,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** @internal */
|
|
26
|
-
export const resolveUniversalChainId = (
|
|
27
|
-
ucid: Domain.UniversalChainId,
|
|
28
|
-
): Effect.Effect<Viem.Chain, Error.SdkError, never> =>
|
|
29
|
-
pipe(
|
|
30
|
-
UniversalChainIdMap,
|
|
31
|
-
R.get(ucid),
|
|
32
|
-
O.match({
|
|
33
|
-
onNone: () =>
|
|
34
|
-
Effect.fail(
|
|
35
|
-
new Error.SystemError({
|
|
36
|
-
method: "resolveUniversalChainId",
|
|
37
|
-
module: "EvmWalletClient",
|
|
38
|
-
reason: "InvalidData",
|
|
39
|
-
}),
|
|
40
|
-
),
|
|
41
|
-
onSome: Effect.succeed,
|
|
42
|
-
}),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
18
|
/** @internal */
|
|
46
19
|
export const TypeId: EvmWalletClient.TypeId = Symbol.for(
|
|
47
20
|
"@unionlabs/payments/EvmWalletClient",
|
|
@@ -353,7 +326,6 @@ export const makeViem = (
|
|
|
353
326
|
const sign = Effect.fn("sign")(function* (
|
|
354
327
|
request: ReadonlyArray<Domain.PreparedRequest> | Domain.PreparedRequest,
|
|
355
328
|
) {
|
|
356
|
-
// const chain = yield* resolveUniversalChainId(request.universalChainId);
|
|
357
329
|
const requests = yield* pipe(
|
|
358
330
|
request,
|
|
359
331
|
A.ensure,
|
|
@@ -362,11 +334,12 @@ export const makeViem = (
|
|
|
362
334
|
n,
|
|
363
335
|
Effect.liftPredicate(
|
|
364
336
|
Domain.PreparedRequest.$is("PreparedEvm"),
|
|
365
|
-
(
|
|
337
|
+
(cause) =>
|
|
366
338
|
new Error.SystemError({
|
|
367
339
|
method: "sign",
|
|
368
340
|
module: "EvmWalletClient",
|
|
369
341
|
reason: "InvalidData",
|
|
342
|
+
cause,
|
|
370
343
|
}),
|
|
371
344
|
),
|
|
372
345
|
),
|
|
@@ -474,8 +447,7 @@ export const makeViem = (
|
|
|
474
447
|
const approveZAssetToSpendErc20 = Effect.fn("approveZAssetToSpendErc20")(
|
|
475
448
|
function* (args: Client.WalletClient.ApproveZAssetToSpendErc20) {
|
|
476
449
|
return yield* pipe(
|
|
477
|
-
|
|
478
|
-
ZAssetRegistry.getZAsset(8453n, args.srcErc20Address),
|
|
450
|
+
ZAssetRegistry.getZAsset(args.universalChainId, args.srcErc20Address),
|
|
479
451
|
Effect.mapError(
|
|
480
452
|
(cause) =>
|
|
481
453
|
new Error.SystemError({
|
|
@@ -708,10 +680,8 @@ export const makeViem = (
|
|
|
708
680
|
|
|
709
681
|
const depositUnderlyingZAsset = Effect.fn("depositUnderlyingZAsset")(
|
|
710
682
|
function* (args: Client.WalletClient.DepositUnderlyingZAsset) {
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
args.srcErc20Address,
|
|
714
|
-
).pipe(
|
|
683
|
+
const zAssetAddress = yield* pipe(
|
|
684
|
+
ZAssetRegistry.getZAsset(args.universalChainId, args.srcErc20Address),
|
|
715
685
|
Effect.mapError(
|
|
716
686
|
(cause) =>
|
|
717
687
|
new Error.SystemError({
|
|
@@ -729,17 +699,10 @@ export const makeViem = (
|
|
|
729
699
|
functionName: "deposit",
|
|
730
700
|
args: [args.amount],
|
|
731
701
|
}),
|
|
732
|
-
// Effect.map((data) =>
|
|
733
|
-
// prepareTransactionRequest({
|
|
734
|
-
// to: zAssetAddr,
|
|
735
|
-
// data,
|
|
736
|
-
// chain: wallet.chain,
|
|
737
|
-
// }),
|
|
738
|
-
// ),
|
|
739
702
|
Effect.map((data) =>
|
|
740
703
|
Domain.PreparedRequest.PreparedEvm({
|
|
741
704
|
...data,
|
|
742
|
-
contractAddress: Domain.Erc20Address(
|
|
705
|
+
contractAddress: Domain.Erc20Address(zAssetAddress),
|
|
743
706
|
universalChainId: args.universalChainId,
|
|
744
707
|
kind: "Erc20.Wrap",
|
|
745
708
|
}),
|
|
@@ -751,10 +714,8 @@ export const makeViem = (
|
|
|
751
714
|
const transferZAsset = Effect.fn("transferZAsset")(function* (
|
|
752
715
|
args: Client.WalletClient.TransferZAsset,
|
|
753
716
|
) {
|
|
754
|
-
const
|
|
755
|
-
|
|
756
|
-
args.srcErc20Address,
|
|
757
|
-
).pipe(
|
|
717
|
+
const zAssetAddress = yield* pipe(
|
|
718
|
+
ZAssetRegistry.getZAsset(args.universalChainId, args.srcErc20Address),
|
|
758
719
|
Effect.mapError(
|
|
759
720
|
(cause) =>
|
|
760
721
|
new Error.SystemError({
|
|
@@ -772,17 +733,10 @@ export const makeViem = (
|
|
|
772
733
|
functionName: "transfer",
|
|
773
734
|
args: [args.depositAddress, args.amount],
|
|
774
735
|
}),
|
|
775
|
-
// Effect.flatMap((data) =>
|
|
776
|
-
// prepareTransactionRequest({
|
|
777
|
-
// to: zAssetAddr,
|
|
778
|
-
// data,
|
|
779
|
-
// chain: wallet.chain,
|
|
780
|
-
// }),
|
|
781
|
-
// ),
|
|
782
736
|
Effect.map((data) =>
|
|
783
737
|
Domain.PreparedRequest.PreparedEvm({
|
|
784
738
|
...data,
|
|
785
|
-
contractAddress: Domain.Erc20Address(
|
|
739
|
+
contractAddress: Domain.Erc20Address(zAssetAddress),
|
|
786
740
|
universalChainId: args.universalChainId,
|
|
787
741
|
kind: "ZAsset.Transfer",
|
|
788
742
|
}),
|
|
@@ -793,19 +747,18 @@ export const makeViem = (
|
|
|
793
747
|
const prepareDeposit = Effect.fn("prepareDeposit")(function* (
|
|
794
748
|
args: Client.WalletClient.Deposit,
|
|
795
749
|
) {
|
|
796
|
-
const zAssetAddress =
|
|
797
|
-
ZAssetRegistry.
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}
|
|
750
|
+
const zAssetAddress = yield* pipe(
|
|
751
|
+
ZAssetRegistry.getZAsset(args.destinationChainId, args.srcErc20Address),
|
|
752
|
+
Effect.mapError(
|
|
753
|
+
(cause) =>
|
|
754
|
+
new Error.SystemError({
|
|
755
|
+
method: "prepareDeposit",
|
|
756
|
+
module: "EvmWalletClient",
|
|
757
|
+
reason: "InvalidData",
|
|
758
|
+
cause,
|
|
759
|
+
}),
|
|
760
|
+
),
|
|
761
|
+
);
|
|
809
762
|
|
|
810
763
|
const [approval, deposit, transfer] = yield* Effect.all(
|
|
811
764
|
[
|
|
@@ -819,7 +772,7 @@ export const makeViem = (
|
|
|
819
772
|
Domain.PreparedRequest.PreparedEvm({
|
|
820
773
|
...data,
|
|
821
774
|
contractAddress: args.srcErc20Address,
|
|
822
|
-
universalChainId: args.
|
|
775
|
+
universalChainId: args.destinationChainId,
|
|
823
776
|
kind: "Erc20.Approve",
|
|
824
777
|
}),
|
|
825
778
|
),
|
|
@@ -834,7 +787,7 @@ export const makeViem = (
|
|
|
834
787
|
Domain.PreparedRequest.PreparedEvm({
|
|
835
788
|
...data,
|
|
836
789
|
contractAddress: Domain.Erc20Address(zAssetAddress),
|
|
837
|
-
universalChainId: args.
|
|
790
|
+
universalChainId: args.destinationChainId,
|
|
838
791
|
kind: "Erc20.Wrap",
|
|
839
792
|
}),
|
|
840
793
|
),
|
|
@@ -849,7 +802,7 @@ export const makeViem = (
|
|
|
849
802
|
Domain.PreparedRequest.PreparedEvm({
|
|
850
803
|
...data,
|
|
851
804
|
contractAddress: Domain.Erc20Address(zAssetAddress),
|
|
852
|
-
universalChainId: args.
|
|
805
|
+
universalChainId: args.destinationChainId,
|
|
853
806
|
kind: "ZAsset.Transfer",
|
|
854
807
|
}),
|
|
855
808
|
),
|
|
@@ -866,20 +819,19 @@ export const makeViem = (
|
|
|
866
819
|
const prepareRedemption = Effect.fn("prepareRedemption")(function* (
|
|
867
820
|
args: Client.WalletClient.Redeem,
|
|
868
821
|
) {
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
args.dstErc20Address,
|
|
872
|
-
).pipe(
|
|
822
|
+
const zAssetAddress = yield* pipe(
|
|
823
|
+
ZAssetRegistry.getZAsset(args.universalChainId, args.dstErc20Address),
|
|
873
824
|
Effect.mapError(
|
|
874
825
|
(cause) =>
|
|
875
826
|
new Error.SystemError({
|
|
876
|
-
method: "
|
|
827
|
+
method: "prepareRedemption",
|
|
877
828
|
module: "EvmWalletClient",
|
|
878
829
|
reason: "InvalidData",
|
|
879
830
|
cause,
|
|
880
831
|
}),
|
|
881
832
|
),
|
|
882
833
|
);
|
|
834
|
+
|
|
883
835
|
return yield* pipe(
|
|
884
836
|
validateFunctionData({
|
|
885
837
|
abi: Abi.ZASSET_ABI,
|
|
@@ -897,17 +849,10 @@ export const makeViem = (
|
|
|
897
849
|
args.unwrap ?? true,
|
|
898
850
|
],
|
|
899
851
|
}),
|
|
900
|
-
// Effect.flatMap((data) =>
|
|
901
|
-
// prepareTransactionRequest({
|
|
902
|
-
// to: zAssetAddr,
|
|
903
|
-
// data,
|
|
904
|
-
// chain: wallet.chain,
|
|
905
|
-
// }),
|
|
906
|
-
// ),
|
|
907
852
|
Effect.map((data) =>
|
|
908
853
|
Domain.PreparedRequest.PreparedEvm({
|
|
909
854
|
...data,
|
|
910
|
-
contractAddress: Domain.Erc20Address(
|
|
855
|
+
contractAddress: Domain.Erc20Address(zAssetAddress),
|
|
911
856
|
universalChainId: args.universalChainId,
|
|
912
857
|
kind: "ZAsset.Transfer",
|
|
913
858
|
}),
|
|
Binary file
|
package/src/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.55.1"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|