@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.
Files changed (53) hide show
  1. package/ChainRegistry/package.json +6 -0
  2. package/README.md +283 -1
  3. package/dist/cjs/ChainRegistry.js +24 -0
  4. package/dist/cjs/ChainRegistry.js.map +1 -0
  5. package/dist/cjs/Payment.js +10 -8
  6. package/dist/cjs/Payment.js.map +1 -1
  7. package/dist/cjs/WalletClient.js.map +1 -1
  8. package/dist/cjs/constants/ibc-core-registry.js +5 -7
  9. package/dist/cjs/constants/ibc-core-registry.js.map +1 -1
  10. package/dist/cjs/constants/z-asset-registry.js +9 -7
  11. package/dist/cjs/constants/z-asset-registry.js.map +1 -1
  12. package/dist/cjs/internal/evmWalletClient.js +24 -69
  13. package/dist/cjs/internal/evmWalletClient.js.map +1 -1
  14. package/dist/dts/ChainRegistry.d.ts +6 -0
  15. package/dist/dts/ChainRegistry.d.ts.map +1 -0
  16. package/dist/dts/Payment.d.ts +7 -8
  17. package/dist/dts/Payment.d.ts.map +1 -1
  18. package/dist/dts/PublicClient.d.ts +4 -4
  19. package/dist/dts/PublicClient.d.ts.map +1 -1
  20. package/dist/dts/WalletClient.d.ts +1 -3
  21. package/dist/dts/WalletClient.d.ts.map +1 -1
  22. package/dist/dts/constants/ibc-core-registry.d.ts +4 -4
  23. package/dist/dts/constants/ibc-core-registry.d.ts.map +1 -1
  24. package/dist/dts/constants/z-asset-registry.d.ts +4 -4
  25. package/dist/dts/constants/z-asset-registry.d.ts.map +1 -1
  26. package/dist/dts/promises/Payment.d.ts +3 -3
  27. package/dist/esm/ChainRegistry.js +16 -0
  28. package/dist/esm/ChainRegistry.js.map +1 -0
  29. package/dist/esm/Payment.js +10 -8
  30. package/dist/esm/Payment.js.map +1 -1
  31. package/dist/esm/Schema.js +4 -8
  32. package/dist/esm/Schema.js.map +1 -1
  33. package/dist/esm/WalletClient.js.map +1 -1
  34. package/dist/esm/constants/ibc-core-registry.js +3 -4
  35. package/dist/esm/constants/ibc-core-registry.js.map +1 -1
  36. package/dist/esm/constants/z-asset-registry.js +7 -4
  37. package/dist/esm/constants/z-asset-registry.js.map +1 -1
  38. package/dist/esm/internal/evmWalletClient.js +23 -67
  39. package/dist/esm/internal/evmWalletClient.js.map +1 -1
  40. package/package.json +9 -1
  41. package/src/ChainRegistry.ts +27 -0
  42. package/src/Payment.ts +33 -25
  43. package/src/PublicClient.ts +4 -4
  44. package/src/WalletClient.ts +1 -3
  45. package/src/constants/ibc-core-registry.ts +11 -7
  46. package/src/constants/z-asset-registry.ts +10 -7
  47. package/src/internal/evmWalletClient.ts +29 -84
  48. package/unionlabs-payments-0.3.1.tgz +0 -0
  49. package/src/tsdoc-metadata.json +0 -11
  50. package/unionlabs-payments-0.3.0.tgz +0 -0
  51. /package/{constants → Constants}/ibc-core-registry/package.json +0 -0
  52. /package/{constants → Constants}/services/package.json +0 -0
  53. /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 universalChainId: Domain.UniversalChainId;
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: bigint;
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: bigint;
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
- options.destinationChainId,
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: bigint;
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
- Effect.try({
141
- try: () =>
142
- Poseidon2.computeNullifier(
143
- options.paymentKey,
144
- options.destinationChainId,
145
- ),
146
- catch: (cause) =>
147
- new Error.SystemError({
148
- method: "getNullifier",
149
- module: "PaymentClient",
150
- reason: "InvalidData",
151
- cause,
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
- Effect.map(Domain.Nullifier),
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: bigint;
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: options.depositAddress.destinationChainId,
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.depositAddress.destinationChainId,
546
- universalChainId: options.universalChainId,
554
+ destinationChainId: options.destinationChainId,
547
555
  });
548
556
  }),
549
557
  );
@@ -120,9 +120,9 @@ export namespace PublicClient {
120
120
  */
121
121
  export interface ReadBalanceOptions {
122
122
  readonly srcErc20Address: Domain.Erc20Address;
123
- readonly srcChainId: bigint;
123
+ readonly srcChainId: Domain.UniversalChainId;
124
124
  readonly dstErc20Address: Domain.Erc20Address;
125
- readonly dstChainId: bigint;
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: bigint;
140
- readonly dstChainId: bigint;
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;
@@ -157,12 +157,10 @@ export namespace WalletClient {
157
157
  }
158
158
 
159
159
  export type Deposit = {
160
- universalChainId: Domain.UniversalChainId;
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: string]: Domain.IbcCoreAddress;
6
+ [chainId: Domain.UniversalChainId]: Domain.IbcCoreAddress;
7
7
  } = {
8
- "8453": Domain.IbcCoreAddress("0xee4ea8d358473f0fcebf0329feed95d56e8c04d7"),
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 function getIbcCoreAddress(
12
- chainId: bigint,
13
- ): Option.Option<Domain.IbcCoreAddress> {
14
- return Option.fromNullable(IBC_CORE_REGISTRY[`${chainId}`]);
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: string]: {
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 function getZAsset(
18
- chainId: bigint,
21
+ export const getZAsset = (
22
+ universalChainId: Domain.UniversalChainId,
19
23
  assetAddress: Erc20Address,
20
- ): Option.Option<Domain.ZAssetAddress> {
21
- return Option.fromNullable(Z_ASSET_REGISTRY[`${chainId}`]?.[assetAddress]);
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
- (x) =>
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
- // XXX: fix hardcoded chainid
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 zAssetAddr = yield* ZAssetRegistry.getZAsset(
712
- 8453n,
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(zAssetAddr),
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 zAssetAddr = yield* ZAssetRegistry.getZAsset(
755
- 8453n,
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(zAssetAddr),
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.Z_ASSET_REGISTRY[`${args.sourceChainId}`][
798
- args.srcErc20Address
799
- ];
800
-
801
- if (!zAssetAddress) {
802
- return yield* new Error.SystemError({
803
- method: "deposit",
804
- module: "PaymentClient",
805
- reason: "InvalidData",
806
- description: `No zAsset found for ${args.srcErc20Address} on chain ${args.sourceChainId}`,
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.universalChainId,
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.universalChainId,
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.universalChainId,
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 zAssetAddr = yield* ZAssetRegistry.getZAsset(
870
- 8453n,
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: "transferZAsset",
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(zAssetAddr),
855
+ contractAddress: Domain.Erc20Address(zAssetAddress),
911
856
  universalChainId: args.universalChainId,
912
857
  kind: "ZAsset.Transfer",
913
858
  }),
Binary file
@@ -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