@circle-fin/app-kit 1.12.0 → 1.13.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/CHANGELOG.md +73 -0
- package/README.md +31 -12
- package/bridge.cjs +3893 -1714
- package/bridge.d.cts +186 -18
- package/bridge.d.mts +186 -18
- package/bridge.d.ts +186 -18
- package/bridge.mjs +3895 -1716
- package/chains.cjs +134 -0
- package/chains.d.cts +126 -1
- package/chains.d.mts +126 -1
- package/chains.d.ts +126 -1
- package/chains.mjs +133 -1
- package/context.d.cts +185 -17
- package/context.d.mts +185 -17
- package/context.d.ts +185 -17
- package/earn.cjs +651 -85
- package/earn.d.cts +185 -17
- package/earn.d.mts +185 -17
- package/earn.d.ts +185 -17
- package/earn.mjs +651 -85
- package/estimateBridge.cjs +3892 -1713
- package/estimateBridge.d.cts +295 -18
- package/estimateBridge.d.mts +295 -18
- package/estimateBridge.d.ts +295 -18
- package/estimateBridge.mjs +3894 -1715
- package/estimateSwap.cjs +748 -136
- package/estimateSwap.d.cts +185 -17
- package/estimateSwap.d.mts +185 -17
- package/estimateSwap.d.ts +185 -17
- package/estimateSwap.mjs +748 -136
- package/index.cjs +3806 -1952
- package/index.d.cts +2775 -1874
- package/index.d.mts +2775 -1874
- package/index.d.ts +2775 -1874
- package/index.mjs +3808 -1954
- package/package.json +6 -6
- package/swap.cjs +748 -136
- package/swap.d.cts +192 -18
- package/swap.d.mts +192 -18
- package/swap.d.ts +192 -18
- package/swap.mjs +748 -136
- package/unifiedBalance.cjs +509 -87
- package/unifiedBalance.d.cts +206 -33
- package/unifiedBalance.d.mts +206 -33
- package/unifiedBalance.d.ts +206 -33
- package/unifiedBalance.mjs +509 -87
package/swap.cjs
CHANGED
|
@@ -2987,6 +2987,8 @@ class KitError extends Error {
|
|
|
2987
2987
|
Blockchain["Optimism_Sepolia"] = "Optimism_Sepolia";
|
|
2988
2988
|
Blockchain["Pharos"] = "Pharos";
|
|
2989
2989
|
Blockchain["Pharos_Testnet"] = "Pharos_Testnet";
|
|
2990
|
+
Blockchain["Plasma"] = "Plasma";
|
|
2991
|
+
Blockchain["Plasma_Testnet"] = "Plasma_Testnet";
|
|
2990
2992
|
Blockchain["Polkadot_Asset_Hub"] = "Polkadot_Asset_Hub";
|
|
2991
2993
|
Blockchain["Polkadot_Westmint"] = "Polkadot_Westmint";
|
|
2992
2994
|
Blockchain["Plume"] = "Plume";
|
|
@@ -3056,6 +3058,7 @@ var BridgeChain;
|
|
|
3056
3058
|
BridgeChain["Morph"] = "Morph";
|
|
3057
3059
|
BridgeChain["Optimism"] = "Optimism";
|
|
3058
3060
|
BridgeChain["Pharos"] = "Pharos";
|
|
3061
|
+
BridgeChain["Plasma"] = "Plasma";
|
|
3059
3062
|
BridgeChain["Plume"] = "Plume";
|
|
3060
3063
|
BridgeChain["Polygon"] = "Polygon";
|
|
3061
3064
|
BridgeChain["Sei"] = "Sei";
|
|
@@ -3082,6 +3085,7 @@ var BridgeChain;
|
|
|
3082
3085
|
BridgeChain["Morph_Testnet"] = "Morph_Testnet";
|
|
3083
3086
|
BridgeChain["Optimism_Sepolia"] = "Optimism_Sepolia";
|
|
3084
3087
|
BridgeChain["Pharos_Testnet"] = "Pharos_Testnet";
|
|
3088
|
+
BridgeChain["Plasma_Testnet"] = "Plasma_Testnet";
|
|
3085
3089
|
BridgeChain["Plume_Testnet"] = "Plume_Testnet";
|
|
3086
3090
|
BridgeChain["Polygon_Amoy_Testnet"] = "Polygon_Amoy_Testnet";
|
|
3087
3091
|
BridgeChain["Sei_Testnet"] = "Sei_Testnet";
|
|
@@ -3539,6 +3543,8 @@ var EarnChain;
|
|
|
3539
3543
|
* This program handles minting operations for Gateway transactions
|
|
3540
3544
|
* on Solana devnet.
|
|
3541
3545
|
*/ const GATEWAY_MINTER_SOLANA_DEVNET = 'GATEmKK2ECL1brEngQZWCgMWPbvrEYqsV6u29dAaHavr';
|
|
3546
|
+
/** TokenMessengerWithFees address shared by enabled EVM mainnet sources. */ const TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET = '0x71f54F818671cD0D7ea140Da213e5C8b5C92a408';
|
|
3547
|
+
/** TokenMessengerWithFees address shared by enabled EVM testnet sources. */ const TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET = '0x8745D906D67C346E5eb1aEEED38Eb87F34DF0C0A';
|
|
3542
3548
|
|
|
3543
3549
|
/**
|
|
3544
3550
|
* Arc Testnet chain definition
|
|
@@ -3576,6 +3582,7 @@ var EarnChain;
|
|
|
3576
3582
|
v2: {
|
|
3577
3583
|
type: 'split',
|
|
3578
3584
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
3585
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3579
3586
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
3580
3587
|
confirmations: 1,
|
|
3581
3588
|
fastConfirmations: 1
|
|
@@ -3643,6 +3650,7 @@ var EarnChain;
|
|
|
3643
3650
|
v2: {
|
|
3644
3651
|
type: 'split',
|
|
3645
3652
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
3653
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
3646
3654
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
3647
3655
|
confirmations: 65,
|
|
3648
3656
|
fastConfirmations: 1
|
|
@@ -3707,6 +3715,7 @@ var EarnChain;
|
|
|
3707
3715
|
v2: {
|
|
3708
3716
|
type: 'split',
|
|
3709
3717
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
3718
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3710
3719
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
3711
3720
|
confirmations: 65,
|
|
3712
3721
|
fastConfirmations: 1
|
|
@@ -3771,6 +3780,7 @@ var EarnChain;
|
|
|
3771
3780
|
v2: {
|
|
3772
3781
|
type: 'split',
|
|
3773
3782
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
3783
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
3774
3784
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
3775
3785
|
confirmations: 1,
|
|
3776
3786
|
fastConfirmations: 1
|
|
@@ -3832,6 +3842,7 @@ var EarnChain;
|
|
|
3832
3842
|
v2: {
|
|
3833
3843
|
type: 'split',
|
|
3834
3844
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
3845
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3835
3846
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
3836
3847
|
confirmations: 1,
|
|
3837
3848
|
fastConfirmations: 1
|
|
@@ -3899,6 +3910,7 @@ var EarnChain;
|
|
|
3899
3910
|
v2: {
|
|
3900
3911
|
type: 'split',
|
|
3901
3912
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
3913
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
3902
3914
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
3903
3915
|
confirmations: 65,
|
|
3904
3916
|
fastConfirmations: 1
|
|
@@ -3963,6 +3975,7 @@ var EarnChain;
|
|
|
3963
3975
|
v2: {
|
|
3964
3976
|
type: 'split',
|
|
3965
3977
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
3978
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3966
3979
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
3967
3980
|
confirmations: 65,
|
|
3968
3981
|
fastConfirmations: 1
|
|
@@ -4073,6 +4086,7 @@ var EarnChain;
|
|
|
4073
4086
|
v2: {
|
|
4074
4087
|
type: 'split',
|
|
4075
4088
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4089
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4076
4090
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4077
4091
|
confirmations: 65,
|
|
4078
4092
|
fastConfirmations: 1
|
|
@@ -4117,6 +4131,7 @@ var EarnChain;
|
|
|
4117
4131
|
v2: {
|
|
4118
4132
|
type: 'split',
|
|
4119
4133
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
4134
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4120
4135
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
4121
4136
|
confirmations: 65,
|
|
4122
4137
|
fastConfirmations: 1
|
|
@@ -4348,6 +4363,7 @@ var EarnChain;
|
|
|
4348
4363
|
v2: {
|
|
4349
4364
|
type: 'split',
|
|
4350
4365
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4366
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4351
4367
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4352
4368
|
confirmations: 65,
|
|
4353
4369
|
fastConfirmations: 2
|
|
@@ -4412,6 +4428,7 @@ var EarnChain;
|
|
|
4412
4428
|
v2: {
|
|
4413
4429
|
type: 'split',
|
|
4414
4430
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
4431
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4415
4432
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
4416
4433
|
confirmations: 65,
|
|
4417
4434
|
fastConfirmations: 2
|
|
@@ -4522,6 +4539,7 @@ var EarnChain;
|
|
|
4522
4539
|
v2: {
|
|
4523
4540
|
type: 'split',
|
|
4524
4541
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4542
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4525
4543
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4526
4544
|
confirmations: 1,
|
|
4527
4545
|
fastConfirmations: 1
|
|
@@ -4581,6 +4599,7 @@ var EarnChain;
|
|
|
4581
4599
|
v2: {
|
|
4582
4600
|
type: 'split',
|
|
4583
4601
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4602
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4584
4603
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4585
4604
|
confirmations: 1,
|
|
4586
4605
|
fastConfirmations: 1
|
|
@@ -4735,6 +4754,7 @@ var EarnChain;
|
|
|
4735
4754
|
v2: {
|
|
4736
4755
|
type: 'split',
|
|
4737
4756
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4757
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4738
4758
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4739
4759
|
confirmations: 65,
|
|
4740
4760
|
fastConfirmations: 1
|
|
@@ -4782,6 +4802,7 @@ var EarnChain;
|
|
|
4782
4802
|
v2: {
|
|
4783
4803
|
type: 'split',
|
|
4784
4804
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4805
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4785
4806
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4786
4807
|
confirmations: 65,
|
|
4787
4808
|
fastConfirmations: 1
|
|
@@ -4826,6 +4847,7 @@ var EarnChain;
|
|
|
4826
4847
|
v2: {
|
|
4827
4848
|
type: 'split',
|
|
4828
4849
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4850
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4829
4851
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4830
4852
|
confirmations: 1,
|
|
4831
4853
|
fastConfirmations: 1
|
|
@@ -4871,6 +4893,7 @@ var EarnChain;
|
|
|
4871
4893
|
v2: {
|
|
4872
4894
|
type: 'split',
|
|
4873
4895
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
4896
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4874
4897
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
4875
4898
|
confirmations: 1,
|
|
4876
4899
|
fastConfirmations: 1
|
|
@@ -4917,6 +4940,7 @@ var EarnChain;
|
|
|
4917
4940
|
v2: {
|
|
4918
4941
|
type: 'split',
|
|
4919
4942
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4943
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4920
4944
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4921
4945
|
confirmations: 1,
|
|
4922
4946
|
fastConfirmations: 1
|
|
@@ -5230,6 +5254,7 @@ var EarnChain;
|
|
|
5230
5254
|
v2: {
|
|
5231
5255
|
type: 'split',
|
|
5232
5256
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5257
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
5233
5258
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5234
5259
|
confirmations: 65,
|
|
5235
5260
|
fastConfirmations: 1
|
|
@@ -5294,6 +5319,7 @@ var EarnChain;
|
|
|
5294
5319
|
v2: {
|
|
5295
5320
|
type: 'split',
|
|
5296
5321
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
5322
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
5297
5323
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
5298
5324
|
confirmations: 65,
|
|
5299
5325
|
fastConfirmations: 1
|
|
@@ -5414,6 +5440,98 @@ var EarnChain;
|
|
|
5414
5440
|
}
|
|
5415
5441
|
});
|
|
5416
5442
|
|
|
5443
|
+
/**
|
|
5444
|
+
* Plasma Mainnet chain definition
|
|
5445
|
+
* @remarks
|
|
5446
|
+
* This represents the official production network for the Plasma blockchain.
|
|
5447
|
+
* Plasma is an EVM-equivalent Layer 1 blockchain purpose-built for global
|
|
5448
|
+
* stablecoin payments, with deterministic BFT finality (PlasmaBFT/Fast-HotStuff).
|
|
5449
|
+
*/ const Plasma = defineChain({
|
|
5450
|
+
type: 'evm',
|
|
5451
|
+
chain: Blockchain.Plasma,
|
|
5452
|
+
name: 'Plasma',
|
|
5453
|
+
title: 'Plasma Mainnet',
|
|
5454
|
+
nativeCurrency: {
|
|
5455
|
+
name: 'Plasma',
|
|
5456
|
+
symbol: 'XPL',
|
|
5457
|
+
decimals: 18
|
|
5458
|
+
},
|
|
5459
|
+
chainId: 9745,
|
|
5460
|
+
isTestnet: false,
|
|
5461
|
+
explorerUrl: 'https://plasmascan.to/tx/{hash}',
|
|
5462
|
+
rpcEndpoints: [
|
|
5463
|
+
'https://rpc.plasma.to'
|
|
5464
|
+
],
|
|
5465
|
+
eurcAddress: '0x3EE196E78d4d4248b849B8E1C7F44C5457FAFD2C',
|
|
5466
|
+
usdcAddress: '0x2d661C89D812261039AF9764eceaAee884f5F67F',
|
|
5467
|
+
usdtAddress: null,
|
|
5468
|
+
cctp: {
|
|
5469
|
+
domain: 33,
|
|
5470
|
+
contracts: {
|
|
5471
|
+
v2: {
|
|
5472
|
+
type: 'split',
|
|
5473
|
+
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5474
|
+
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5475
|
+
confirmations: 3,
|
|
5476
|
+
fastConfirmations: 1
|
|
5477
|
+
}
|
|
5478
|
+
},
|
|
5479
|
+
forwarderSupported: {
|
|
5480
|
+
source: false,
|
|
5481
|
+
destination: false
|
|
5482
|
+
}
|
|
5483
|
+
},
|
|
5484
|
+
kitContracts: {
|
|
5485
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET
|
|
5486
|
+
}
|
|
5487
|
+
});
|
|
5488
|
+
|
|
5489
|
+
/**
|
|
5490
|
+
* Plasma Testnet chain definition
|
|
5491
|
+
* @remarks
|
|
5492
|
+
* This represents the official test network for the Plasma blockchain.
|
|
5493
|
+
* Plasma is an EVM-equivalent Layer 1 blockchain purpose-built for global
|
|
5494
|
+
* stablecoin payments, with deterministic BFT finality (PlasmaBFT/Fast-HotStuff).
|
|
5495
|
+
*/ const PlasmaTestnet = defineChain({
|
|
5496
|
+
type: 'evm',
|
|
5497
|
+
chain: Blockchain.Plasma_Testnet,
|
|
5498
|
+
name: 'Plasma Testnet',
|
|
5499
|
+
title: 'Plasma Testnet',
|
|
5500
|
+
nativeCurrency: {
|
|
5501
|
+
name: 'Plasma',
|
|
5502
|
+
symbol: 'XPL',
|
|
5503
|
+
decimals: 18
|
|
5504
|
+
},
|
|
5505
|
+
chainId: 9746,
|
|
5506
|
+
isTestnet: true,
|
|
5507
|
+
explorerUrl: 'https://testnet.plasmascan.to/tx/{hash}',
|
|
5508
|
+
rpcEndpoints: [
|
|
5509
|
+
'https://testnet-rpc.plasma.to'
|
|
5510
|
+
],
|
|
5511
|
+
eurcAddress: '0x98AfA0F93Dd993B736399f9074eDcEBD1985A330',
|
|
5512
|
+
usdcAddress: '0xE67Fb267022cBA8064Dd388CC2FED724F3120D9D',
|
|
5513
|
+
usdtAddress: null,
|
|
5514
|
+
cctp: {
|
|
5515
|
+
domain: 33,
|
|
5516
|
+
contracts: {
|
|
5517
|
+
v2: {
|
|
5518
|
+
type: 'split',
|
|
5519
|
+
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
5520
|
+
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
5521
|
+
confirmations: 3,
|
|
5522
|
+
fastConfirmations: 1
|
|
5523
|
+
}
|
|
5524
|
+
},
|
|
5525
|
+
forwarderSupported: {
|
|
5526
|
+
source: false,
|
|
5527
|
+
destination: false
|
|
5528
|
+
}
|
|
5529
|
+
},
|
|
5530
|
+
kitContracts: {
|
|
5531
|
+
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
5532
|
+
}
|
|
5533
|
+
});
|
|
5534
|
+
|
|
5417
5535
|
/**
|
|
5418
5536
|
* Plume Mainnet chain definition
|
|
5419
5537
|
* @remarks
|
|
@@ -5445,6 +5563,7 @@ var EarnChain;
|
|
|
5445
5563
|
v2: {
|
|
5446
5564
|
type: 'split',
|
|
5447
5565
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5566
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
5448
5567
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5449
5568
|
confirmations: 65,
|
|
5450
5569
|
fastConfirmations: 1
|
|
@@ -5491,6 +5610,7 @@ var EarnChain;
|
|
|
5491
5610
|
v2: {
|
|
5492
5611
|
type: 'split',
|
|
5493
5612
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
5613
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
5494
5614
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
5495
5615
|
confirmations: 65,
|
|
5496
5616
|
fastConfirmations: 1
|
|
@@ -5592,6 +5712,7 @@ var EarnChain;
|
|
|
5592
5712
|
v2: {
|
|
5593
5713
|
type: 'split',
|
|
5594
5714
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5715
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
5595
5716
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5596
5717
|
confirmations: 33,
|
|
5597
5718
|
fastConfirmations: 13
|
|
@@ -5657,6 +5778,7 @@ var EarnChain;
|
|
|
5657
5778
|
v2: {
|
|
5658
5779
|
type: 'split',
|
|
5659
5780
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
5781
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
5660
5782
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
5661
5783
|
confirmations: 33,
|
|
5662
5784
|
fastConfirmations: 13
|
|
@@ -5716,6 +5838,7 @@ var EarnChain;
|
|
|
5716
5838
|
v2: {
|
|
5717
5839
|
type: 'split',
|
|
5718
5840
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5841
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
5719
5842
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5720
5843
|
confirmations: 1,
|
|
5721
5844
|
fastConfirmations: 1
|
|
@@ -5775,6 +5898,7 @@ var EarnChain;
|
|
|
5775
5898
|
v2: {
|
|
5776
5899
|
type: 'split',
|
|
5777
5900
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
5901
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
5778
5902
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
5779
5903
|
confirmations: 1,
|
|
5780
5904
|
fastConfirmations: 1
|
|
@@ -5832,6 +5956,7 @@ var EarnChain;
|
|
|
5832
5956
|
v2: {
|
|
5833
5957
|
type: 'split',
|
|
5834
5958
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
5959
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
5835
5960
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
5836
5961
|
confirmations: 1,
|
|
5837
5962
|
fastConfirmations: 1
|
|
@@ -5890,6 +6015,7 @@ var EarnChain;
|
|
|
5890
6015
|
v2: {
|
|
5891
6016
|
type: 'split',
|
|
5892
6017
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
6018
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
5893
6019
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
5894
6020
|
confirmations: 1,
|
|
5895
6021
|
fastConfirmations: 1
|
|
@@ -6205,6 +6331,7 @@ var EarnChain;
|
|
|
6205
6331
|
v2: {
|
|
6206
6332
|
type: 'split',
|
|
6207
6333
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
6334
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
6208
6335
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
6209
6336
|
confirmations: 65,
|
|
6210
6337
|
fastConfirmations: 1
|
|
@@ -6269,6 +6396,7 @@ var EarnChain;
|
|
|
6269
6396
|
v2: {
|
|
6270
6397
|
type: 'split',
|
|
6271
6398
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
6399
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
6272
6400
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
6273
6401
|
confirmations: 65,
|
|
6274
6402
|
fastConfirmations: 1
|
|
@@ -6326,6 +6454,7 @@ var EarnChain;
|
|
|
6326
6454
|
v2: {
|
|
6327
6455
|
type: 'split',
|
|
6328
6456
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cF5d',
|
|
6457
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
6329
6458
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
6330
6459
|
confirmations: 65,
|
|
6331
6460
|
fastConfirmations: 1
|
|
@@ -6385,6 +6514,7 @@ var EarnChain;
|
|
|
6385
6514
|
v2: {
|
|
6386
6515
|
type: 'split',
|
|
6387
6516
|
tokenMessenger: '0x8fe6b999dc680ccfdd5bf7eb0974218be2542daa',
|
|
6517
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
6388
6518
|
messageTransmitter: '0xe737e5cebeeba77efe34d4aa090756590b1ce275',
|
|
6389
6519
|
confirmations: 65,
|
|
6390
6520
|
fastConfirmations: 1
|
|
@@ -6445,6 +6575,7 @@ var EarnChain;
|
|
|
6445
6575
|
v2: {
|
|
6446
6576
|
type: 'split',
|
|
6447
6577
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
6578
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
6448
6579
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
6449
6580
|
confirmations: 3,
|
|
6450
6581
|
fastConfirmations: 3
|
|
@@ -6490,6 +6621,7 @@ var EarnChain;
|
|
|
6490
6621
|
v2: {
|
|
6491
6622
|
type: 'split',
|
|
6492
6623
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
6624
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
6493
6625
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
6494
6626
|
confirmations: 3,
|
|
6495
6627
|
fastConfirmations: 1
|
|
@@ -6700,6 +6832,8 @@ var Chains = {
|
|
|
6700
6832
|
OptimismSepolia: OptimismSepolia,
|
|
6701
6833
|
Pharos: Pharos,
|
|
6702
6834
|
PharosTestnet: PharosTestnet,
|
|
6835
|
+
Plasma: Plasma,
|
|
6836
|
+
PlasmaTestnet: PlasmaTestnet,
|
|
6703
6837
|
Plume: Plume,
|
|
6704
6838
|
PlumeTestnet: PlumeTestnet,
|
|
6705
6839
|
PolkadotAssetHub: PolkadotAssetHub,
|
|
@@ -8741,6 +8875,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8741
8875
|
[Blockchain.Noble]: 'uusdc',
|
|
8742
8876
|
[Blockchain.Optimism]: '0x0b2c639c533813f4aa9d7837caf62653d097ff85',
|
|
8743
8877
|
[Blockchain.Pharos]: '0xC879C018dB60520F4355C26eD1a6D572cdAC1815',
|
|
8878
|
+
[Blockchain.Plasma]: '0x2d661C89D812261039AF9764eceaAee884f5F67F',
|
|
8744
8879
|
[Blockchain.Plume]: '0x222365EF19F7947e5484218551B56bb3965Aa7aF',
|
|
8745
8880
|
[Blockchain.Polkadot_Asset_Hub]: '1337',
|
|
8746
8881
|
[Blockchain.Polygon]: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
|
|
@@ -8761,6 +8896,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8761
8896
|
[Blockchain.Arbitrum_Sepolia]: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
|
|
8762
8897
|
[Blockchain.Avalanche_Fuji]: '0x5425890298aed601595a70AB815c96711a31Bc65',
|
|
8763
8898
|
[Blockchain.Base_Sepolia]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
8899
|
+
[Blockchain.Celo_Alfajores_Testnet]: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
|
|
8764
8900
|
[Blockchain.Codex_Testnet]: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f',
|
|
8765
8901
|
[Blockchain.Cronos_Testnet]: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
|
|
8766
8902
|
[Blockchain.Edge_Testnet]: '0x2d9F7CAD728051AA35Ecdc472a14cf8cDF5CFD6B',
|
|
@@ -8776,6 +8912,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8776
8912
|
[Blockchain.Noble_Testnet]: 'uusdc',
|
|
8777
8913
|
[Blockchain.Optimism_Sepolia]: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7',
|
|
8778
8914
|
[Blockchain.Pharos_Testnet]: '0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B',
|
|
8915
|
+
[Blockchain.Plasma_Testnet]: '0xE67Fb267022cBA8064Dd388CC2FED724F3120D9D',
|
|
8779
8916
|
[Blockchain.Plume_Testnet]: '0xcB5f30e335672893c7eb944B374c196392C19D18',
|
|
8780
8917
|
[Blockchain.Polkadot_Westmint]: '31337',
|
|
8781
8918
|
[Blockchain.Polygon_Amoy_Testnet]: '0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582',
|
|
@@ -8838,6 +8975,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8838
8975
|
[Blockchain.Base]: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
|
|
8839
8976
|
[Blockchain.Cronos]: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
|
|
8840
8977
|
[Blockchain.Ethereum]: '0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
|
|
8978
|
+
[Blockchain.Plasma]: '0x3EE196E78d4d4248b849B8E1C7F44C5457FAFD2C',
|
|
8841
8979
|
[Blockchain.Solana]: 'HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr',
|
|
8842
8980
|
[Blockchain.World_Chain]: '0x1C60ba0A0eD1019e8Eb035E6daF4155A5cE2380B',
|
|
8843
8981
|
// =========================================================================
|
|
@@ -8846,7 +8984,8 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8846
8984
|
[Blockchain.Arc_Testnet]: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
|
|
8847
8985
|
[Blockchain.Base_Sepolia]: '0x808456652fdb597867f38412077A9182bf77359F',
|
|
8848
8986
|
[Blockchain.Cronos_Testnet]: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46',
|
|
8849
|
-
[Blockchain.Ethereum_Sepolia]: '0x08210F9170F89Ab7658F0B5E3fF39b0E03C594D4'
|
|
8987
|
+
[Blockchain.Ethereum_Sepolia]: '0x08210F9170F89Ab7658F0B5E3fF39b0E03C594D4',
|
|
8988
|
+
[Blockchain.Plasma_Testnet]: '0x98AfA0F93Dd993B736399f9074eDcEBD1985A330'
|
|
8850
8989
|
}
|
|
8851
8990
|
};
|
|
8852
8991
|
|
|
@@ -10075,7 +10214,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
10075
10214
|
}
|
|
10076
10215
|
|
|
10077
10216
|
var name$2 = "@circle-fin/bridge-kit";
|
|
10078
|
-
var version$2 = "1.
|
|
10217
|
+
var version$2 = "1.14.0";
|
|
10079
10218
|
var pkg$2 = {
|
|
10080
10219
|
name: name$2,
|
|
10081
10220
|
version: version$2};
|
|
@@ -10128,6 +10267,44 @@ var pkg$2 = {
|
|
|
10128
10267
|
}
|
|
10129
10268
|
});
|
|
10130
10269
|
|
|
10270
|
+
/**
|
|
10271
|
+
* Canonical list of actions that do not prepare or submit transactions.
|
|
10272
|
+
*
|
|
10273
|
+
* @internal
|
|
10274
|
+
*/ const READ_ACTION_KEYS = [
|
|
10275
|
+
'token.allowance',
|
|
10276
|
+
'token.balanceOf',
|
|
10277
|
+
'token.name',
|
|
10278
|
+
'native.balanceOf',
|
|
10279
|
+
'usdc.allowance',
|
|
10280
|
+
'usdc.balanceOf',
|
|
10281
|
+
'usdc.name',
|
|
10282
|
+
'gateway.v1.isDelegate',
|
|
10283
|
+
'gateway.v1.withdrawingBalance',
|
|
10284
|
+
'gateway.v1.withdrawalBlock',
|
|
10285
|
+
'gateway.v1.signBurnIntents'
|
|
10286
|
+
];
|
|
10287
|
+
const READ_ACTION_KEY_SET = new Set(READ_ACTION_KEYS);
|
|
10288
|
+
/**
|
|
10289
|
+
* Check whether a runtime value identifies a read action.
|
|
10290
|
+
*
|
|
10291
|
+
* @param action - The value to classify.
|
|
10292
|
+
* @returns Whether the value is a registered read-action key.
|
|
10293
|
+
*
|
|
10294
|
+
* @example
|
|
10295
|
+
* ```typescript
|
|
10296
|
+
* import { isReadActionKey } from '@core/adapter'
|
|
10297
|
+
*
|
|
10298
|
+
* if (isReadActionKey(value)) {
|
|
10299
|
+
* await adapter.readAction(value, params, context)
|
|
10300
|
+
* }
|
|
10301
|
+
* ```
|
|
10302
|
+
*
|
|
10303
|
+
* @internal
|
|
10304
|
+
*/ function isReadActionKey(action) {
|
|
10305
|
+
return typeof action === 'string' && READ_ACTION_KEY_SET.has(action);
|
|
10306
|
+
}
|
|
10307
|
+
|
|
10131
10308
|
/**
|
|
10132
10309
|
* Resolves an operation context into concrete chain and address values.
|
|
10133
10310
|
*
|
|
@@ -10207,6 +10384,141 @@ var pkg$2 = {
|
|
|
10207
10384
|
};
|
|
10208
10385
|
}
|
|
10209
10386
|
|
|
10387
|
+
/**
|
|
10388
|
+
* Create the standard error for a missing or non-read action.
|
|
10389
|
+
*
|
|
10390
|
+
* @param action - The unsupported action value.
|
|
10391
|
+
* @returns A fatal unsupported-action error.
|
|
10392
|
+
*
|
|
10393
|
+
* @internal
|
|
10394
|
+
*/ function createUnsupportedReadActionError(action) {
|
|
10395
|
+
return new KitError({
|
|
10396
|
+
...InputError.UNSUPPORTED_ACTION,
|
|
10397
|
+
recoverability: 'FATAL',
|
|
10398
|
+
message: `Read action "${String(action)}" is not registered in this adapter.`
|
|
10399
|
+
});
|
|
10400
|
+
}
|
|
10401
|
+
/**
|
|
10402
|
+
* Execute a read through the adapter's dedicated read seam when available.
|
|
10403
|
+
*
|
|
10404
|
+
* @remarks
|
|
10405
|
+
* Fall back to the legacy `prepareAction().execute()` contract so providers
|
|
10406
|
+
* remain runtime-compatible with adapter versions released before `readAction`.
|
|
10407
|
+
* Consumers must upgrade their adapter package for reads to bypass custom
|
|
10408
|
+
* `prepareAction` wrappers.
|
|
10409
|
+
*
|
|
10410
|
+
* @typeParam TAdapterCapabilities - The adapter capabilities type.
|
|
10411
|
+
* @typeParam TActionKey - The read action key.
|
|
10412
|
+
* @param adapter - The adapter that owns the read action.
|
|
10413
|
+
* @param action - The read action to execute.
|
|
10414
|
+
* @param params - The parameters for the read action.
|
|
10415
|
+
* @param ctx - The operation context.
|
|
10416
|
+
* @returns The raw read-action result.
|
|
10417
|
+
* @throws {KitError} When `action` is not a supported read-action key.
|
|
10418
|
+
*
|
|
10419
|
+
* @example
|
|
10420
|
+
* ```typescript
|
|
10421
|
+
* import { executeAdapterReadAction } from '@core/adapter'
|
|
10422
|
+
* import { Ethereum } from '@core/chains'
|
|
10423
|
+
*
|
|
10424
|
+
* const allowance = await executeAdapterReadAction(
|
|
10425
|
+
* adapter,
|
|
10426
|
+
* 'token.allowance',
|
|
10427
|
+
* { tokenAddress, delegate },
|
|
10428
|
+
* { chain: Ethereum },
|
|
10429
|
+
* )
|
|
10430
|
+
* ```
|
|
10431
|
+
*
|
|
10432
|
+
* @internal
|
|
10433
|
+
*/ async function executeAdapterReadAction(adapter, action, params, ctx) {
|
|
10434
|
+
if (!isReadActionKey(action)) {
|
|
10435
|
+
throw createUnsupportedReadActionError(action);
|
|
10436
|
+
}
|
|
10437
|
+
const runtimeAdapter = adapter;
|
|
10438
|
+
if (typeof runtimeAdapter.readAction === 'function') {
|
|
10439
|
+
return runtimeAdapter.readAction(action, params, ctx);
|
|
10440
|
+
}
|
|
10441
|
+
let request;
|
|
10442
|
+
try {
|
|
10443
|
+
request = await adapter.prepareAction(action, params, ctx);
|
|
10444
|
+
} catch (error) {
|
|
10445
|
+
if (error instanceof Error && error.message === `Action ${action} is not supported`) {
|
|
10446
|
+
throw createUnsupportedReadActionError(action);
|
|
10447
|
+
}
|
|
10448
|
+
throw error;
|
|
10449
|
+
}
|
|
10450
|
+
return request.execute();
|
|
10451
|
+
}
|
|
10452
|
+
/**
|
|
10453
|
+
* Read and parse a token allowance while supporting older adapter versions.
|
|
10454
|
+
*
|
|
10455
|
+
* @remarks
|
|
10456
|
+
* Prefer the adapter's dedicated read seam and fall back to the legacy
|
|
10457
|
+
* `prepareAction().execute()` contract when the runtime adapter predates it.
|
|
10458
|
+
*
|
|
10459
|
+
* @typeParam TAdapterCapabilities - The adapter capabilities type.
|
|
10460
|
+
* @param adapter - The adapter that owns the allowance action.
|
|
10461
|
+
* @param params - The token and delegate whose allowance is being read.
|
|
10462
|
+
* @param ctx - The operation context.
|
|
10463
|
+
* @returns The non-negative allowance in token base units.
|
|
10464
|
+
* @throws {KitError} When the action is unsupported or its response is malformed.
|
|
10465
|
+
*
|
|
10466
|
+
* @example
|
|
10467
|
+
* ```typescript
|
|
10468
|
+
* import { readTokenAllowance } from '@core/adapter'
|
|
10469
|
+
* import { Ethereum } from '@core/chains'
|
|
10470
|
+
*
|
|
10471
|
+
* const allowance = await readTokenAllowance(
|
|
10472
|
+
* adapter,
|
|
10473
|
+
* { tokenAddress, delegate },
|
|
10474
|
+
* { chain: Ethereum },
|
|
10475
|
+
* )
|
|
10476
|
+
* ```
|
|
10477
|
+
*
|
|
10478
|
+
* @internal
|
|
10479
|
+
*/ async function readTokenAllowance(adapter, params, ctx) {
|
|
10480
|
+
return parseAllowanceResponse(await executeAdapterReadAction(adapter, 'token.allowance', params, ctx));
|
|
10481
|
+
}
|
|
10482
|
+
/**
|
|
10483
|
+
* Parse a raw token allowance response into base units.
|
|
10484
|
+
*
|
|
10485
|
+
* @param allowanceRaw - The adapter response, optionally wrapped as an Amount output.
|
|
10486
|
+
* @returns The non-negative allowance as a bigint, or zero for a missing value.
|
|
10487
|
+
* @throws {KitError} When the response cannot represent a non-negative bigint.
|
|
10488
|
+
*
|
|
10489
|
+
* @example
|
|
10490
|
+
* ```typescript
|
|
10491
|
+
* import { parseAllowanceResponse } from '@core/adapter'
|
|
10492
|
+
*
|
|
10493
|
+
* const allowance = parseAllowanceResponse({ amount: { raw: 1000000n } })
|
|
10494
|
+
* ```
|
|
10495
|
+
*/ function parseAllowanceResponse(allowanceRaw) {
|
|
10496
|
+
let value = allowanceRaw;
|
|
10497
|
+
if (typeof value === 'object' && value !== null && 'amount' in value) {
|
|
10498
|
+
const amount = value.amount;
|
|
10499
|
+
if (typeof amount === 'object' && amount !== null && 'raw' in amount) {
|
|
10500
|
+
value = amount.raw;
|
|
10501
|
+
}
|
|
10502
|
+
}
|
|
10503
|
+
if (value === undefined || value === null) {
|
|
10504
|
+
return 0n;
|
|
10505
|
+
}
|
|
10506
|
+
let allowance;
|
|
10507
|
+
if (typeof value === 'bigint') {
|
|
10508
|
+
allowance = value;
|
|
10509
|
+
} else if (typeof value === 'string') {
|
|
10510
|
+
try {
|
|
10511
|
+
allowance = BigInt(value);
|
|
10512
|
+
} catch {
|
|
10513
|
+
allowance = undefined;
|
|
10514
|
+
}
|
|
10515
|
+
}
|
|
10516
|
+
if (allowance === undefined || allowance < 0n) {
|
|
10517
|
+
throw createValidationFailedError$1('token.allowance', value, 'token.allowance response must be a non-negative bigint-compatible string or bigint');
|
|
10518
|
+
}
|
|
10519
|
+
return allowance;
|
|
10520
|
+
}
|
|
10521
|
+
|
|
10210
10522
|
/**
|
|
10211
10523
|
* Schema for validating hexadecimal strings with '0x' prefix.
|
|
10212
10524
|
*
|
|
@@ -10256,7 +10568,7 @@ var pkg$2 = {
|
|
|
10256
10568
|
* const result = evmAddressSchema.safeParse(validAddress)
|
|
10257
10569
|
* console.log(result.success) // true
|
|
10258
10570
|
* ```
|
|
10259
|
-
*/ const evmAddressSchema = hexStringSchema.refine((value)=>value.length === 42, 'EVM address must be exactly 42 characters long (0x + 40 hex characters)').transform((value)=>value);
|
|
10571
|
+
*/ const evmAddressSchema$1 = hexStringSchema.refine((value)=>value.length === 42, 'EVM address must be exactly 42 characters long (0x + 40 hex characters)').transform((value)=>value);
|
|
10260
10572
|
/**
|
|
10261
10573
|
* Schema for validating transaction hashes.
|
|
10262
10574
|
*
|
|
@@ -10793,6 +11105,10 @@ var TransferSpeed;
|
|
|
10793
11105
|
token: zod.z.literal('USDC').optional(),
|
|
10794
11106
|
config: zod.z.object({
|
|
10795
11107
|
transferSpeed: zod.z.nativeEnum(TransferSpeed).optional(),
|
|
11108
|
+
feePayment: zod.z.enum([
|
|
11109
|
+
'source',
|
|
11110
|
+
'destination'
|
|
11111
|
+
]).optional(),
|
|
10796
11112
|
maxFee: zod.z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
10797
11113
|
allowZero: true,
|
|
10798
11114
|
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
@@ -10800,7 +11116,8 @@ var TransferSpeed;
|
|
|
10800
11116
|
maxDecimals: 6
|
|
10801
11117
|
})(zod.z.string())).optional(),
|
|
10802
11118
|
customFee: customFeeSchema.optional()
|
|
10803
|
-
}).optional()
|
|
11119
|
+
}).optional(),
|
|
11120
|
+
quote: zod.z.string().regex(/^0x([a-fA-F0-9]{2})+$/, 'must be non-empty 0x hex').optional()
|
|
10804
11121
|
});
|
|
10805
11122
|
|
|
10806
11123
|
/**
|
|
@@ -10978,13 +11295,182 @@ var TransferSpeed;
|
|
|
10978
11295
|
* @internal
|
|
10979
11296
|
*/ Object.values(Chains).filter((chain)=>isCCTPV2Supported(chain));
|
|
10980
11297
|
|
|
11298
|
+
/** Decimal string in token minor units, constrained to be strictly positive. */ const positiveAmountSchema = zod.z.string().regex(/^\d+$/, 'must be a non-negative integer string')// Re-check the digit shape here: zod still runs this refinement when the
|
|
11299
|
+
// regex check above fails ("dirty"), so guard BigInt() against throwing on a
|
|
11300
|
+
// non-numeric value before comparing.
|
|
11301
|
+
.refine((value)=>/^\d+$/.test(value) && BigInt(value) > 0n, 'must be greater than zero');
|
|
11302
|
+
/**
|
|
11303
|
+
* A 20-byte EVM address in `0x` hex.
|
|
11304
|
+
*
|
|
11305
|
+
* The MVP prepaid-`FORWARD` `burn/usdc` path targets EVM contracts
|
|
11306
|
+
* (`TokenMessengerWithFees` / `GenericExecutor`), so `feeToken` and
|
|
11307
|
+
* `destinationCaller` are constrained to EVM addresses by design. This is an
|
|
11308
|
+
* intentional scope limit, not a permanent one: it can be widened to other
|
|
11309
|
+
* address formats as the fee service expands to more chains.
|
|
11310
|
+
*/ const evmAddressSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 20-byte 0x address');
|
|
11311
|
+
/** Even-length `0x` hex (the empty `0x` is allowed). */ const hexSchema = zod.z.string().regex(/^0x([a-fA-F0-9]{2})*$/, 'must be even-length 0x hex');
|
|
11312
|
+
/** Non-empty, even-length `0x` hex. */ const nonEmptyHexSchema = zod.z.string().regex(/^0x([a-fA-F0-9]{2})+$/, 'must be non-empty 0x hex');
|
|
11313
|
+
/** A 32-byte `0x` hex hash. */ const bytes32Schema = zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 32-byte 0x hash');
|
|
11314
|
+
/** Decimal string in minor units, allowing zero. */ const numericStringSchema = zod.z.string().regex(/^\d+$/, 'must be a non-negative integer string');
|
|
11315
|
+
/** An `https:` URL, used for the optional base-URL override. */ const httpsUrlSchema = zod.z.string().refine((value)=>{
|
|
11316
|
+
try {
|
|
11317
|
+
return new URL(value).protocol === 'https:';
|
|
11318
|
+
} catch {
|
|
11319
|
+
return false;
|
|
11320
|
+
}
|
|
11321
|
+
}, 'must be an https URL');
|
|
11322
|
+
const forwardParamsSchema = zod.z.object({
|
|
11323
|
+
hookData: hexSchema.optional(),
|
|
11324
|
+
destinationCaller: evmAddressSchema.optional()
|
|
11325
|
+
}).strict();
|
|
11326
|
+
const forwardRequestSchema = zod.z.object({
|
|
11327
|
+
type: zod.z.literal('FORWARD'),
|
|
11328
|
+
params: forwardParamsSchema.optional()
|
|
11329
|
+
}).strict();
|
|
11330
|
+
const preFinalityRequestSchema = zod.z.object({
|
|
11331
|
+
type: zod.z.literal('PRE_FINALITY')
|
|
11332
|
+
}).strict();
|
|
11333
|
+
/** A single quote request item (`FORWARD` or `PRE_FINALITY`). */ const feeQuoteRequestSchema = zod.z.discriminatedUnion('type', [
|
|
11334
|
+
forwardRequestSchema,
|
|
11335
|
+
preFinalityRequestSchema
|
|
11336
|
+
]);
|
|
11337
|
+
/** A non-empty list of quote request items with unique types. */ const feeQuoteRequestsSchema = zod.z.array(feeQuoteRequestSchema).min(1, 'at least one request item is required').refine((items)=>new Set(items.map((item)=>item.type)).size === items.length, 'request item types must be unique');
|
|
11338
|
+
/**
|
|
11339
|
+
* A structured `Partial<ApiPollingConfig>` polling override.
|
|
11340
|
+
*
|
|
11341
|
+
* Validates the field types callers actually set, so a plain-JS caller passing
|
|
11342
|
+
* `{ timeout: 'soon' }` is rejected at the boundary rather than failing opaquely
|
|
11343
|
+
* inside the transport. Unknown keys pass through so a future `ApiPollingConfig`
|
|
11344
|
+
* field is forwarded rather than silently dropped.
|
|
11345
|
+
*/ const apiPollingConfigSchema = zod.z.object({
|
|
11346
|
+
timeout: zod.z.number().int().positive().optional(),
|
|
11347
|
+
maxRetries: zod.z.number().int().nonnegative().optional(),
|
|
11348
|
+
retryDelay: zod.z.number().int().nonnegative().optional(),
|
|
11349
|
+
backoff: zod.z.enum([
|
|
11350
|
+
'fixed',
|
|
11351
|
+
'exponential'
|
|
11352
|
+
]).optional(),
|
|
11353
|
+
maxRetryDelayMs: zod.z.number().int().positive().optional(),
|
|
11354
|
+
headers: zod.z.record(zod.z.string()).optional()
|
|
11355
|
+
}).passthrough();
|
|
11356
|
+
/**
|
|
11357
|
+
* The validatable input for {@link fetchFeeQuote}.
|
|
11358
|
+
*
|
|
11359
|
+
* This is the single source of truth for input validation, including the CCTP
|
|
11360
|
+
* domains and the `isTestnet` environment flag. Validating `isTestnet` at
|
|
11361
|
+
* runtime matters because a plain-JS caller who omits it would otherwise leave
|
|
11362
|
+
* it `undefined`, which is falsy and silently selects the production base URL.
|
|
11363
|
+
* (`buildFeeQuoteUrl` independently re-validates the domains for standalone
|
|
11364
|
+
* callers.)
|
|
11365
|
+
*/ zod.z.object({
|
|
11366
|
+
sourceDomain: zod.z.number().int().nonnegative(),
|
|
11367
|
+
destinationDomain: zod.z.number().int().nonnegative(),
|
|
11368
|
+
amount: positiveAmountSchema,
|
|
11369
|
+
feeToken: evmAddressSchema.optional(),
|
|
11370
|
+
requests: feeQuoteRequestsSchema,
|
|
11371
|
+
isTestnet: zod.z.boolean(),
|
|
11372
|
+
baseUrl: httpsUrlSchema.optional(),
|
|
11373
|
+
config: apiPollingConfigSchema.optional()
|
|
11374
|
+
}).strict();
|
|
11375
|
+
const feeQuoteItemSchema = zod.z.object({
|
|
11376
|
+
type: zod.z.string().min(1),
|
|
11377
|
+
amount: numericStringSchema,
|
|
11378
|
+
args: zod.z.array(zod.z.string()),
|
|
11379
|
+
argsHash: bytes32Schema
|
|
11380
|
+
}).passthrough();
|
|
11381
|
+
const exchangeRatesSchema = zod.z.object({
|
|
11382
|
+
feeTokenUsd: zod.z.string(),
|
|
11383
|
+
destinationTokenUsd: zod.z.string()
|
|
11384
|
+
}).passthrough();
|
|
11385
|
+
const metadataSchema = zod.z.object({
|
|
11386
|
+
destinationGasPrice: zod.z.string().optional(),
|
|
11387
|
+
exchangeRates: exchangeRatesSchema.optional()
|
|
11388
|
+
}).passthrough();
|
|
11389
|
+
/** The `expiry` object the Quote API nests the quote TTL under. */ const expirySchema = zod.z.discriminatedUnion('mode', [
|
|
11390
|
+
zod.z.object({
|
|
11391
|
+
mode: zod.z.literal('TIMESTAMP'),
|
|
11392
|
+
expiresAt: zod.z.number().int().nonnegative()
|
|
11393
|
+
}).passthrough(),
|
|
11394
|
+
zod.z.object({
|
|
11395
|
+
mode: zod.z.literal('BLOCK_NUMBER'),
|
|
11396
|
+
expiresAtBlock: zod.z.number().int().nonnegative(),
|
|
11397
|
+
blockEstimatedAt: zod.z.number().int().nonnegative().optional()
|
|
11398
|
+
}).passthrough()
|
|
11399
|
+
]);
|
|
11400
|
+
/** Schema for a signed fee quote returned by the Quote API. */ zod.z.object({
|
|
11401
|
+
// The runtime YAML spec maps signedQuote to a looser `hex` (which allows
|
|
11402
|
+
// an empty `0x`); we keep the stricter non-empty form. Do not relax
|
|
11403
|
+
// without a reason.
|
|
11404
|
+
signedQuote: nonEmptyHexSchema,
|
|
11405
|
+
issuedAt: zod.z.number().int().nonnegative(),
|
|
11406
|
+
// The API returns a mode-specific timestamp or source-block deadline.
|
|
11407
|
+
expiry: expirySchema,
|
|
11408
|
+
feeTotalAmount: numericStringSchema,
|
|
11409
|
+
feeToken: evmAddressSchema,
|
|
11410
|
+
nonce: numericStringSchema,
|
|
11411
|
+
items: zod.z.array(feeQuoteItemSchema),
|
|
11412
|
+
metadata: metadataSchema.optional()
|
|
11413
|
+
}).passthrough();
|
|
11414
|
+
/** Validate input to {@link validateQuote}. */ zod.z.object({
|
|
11415
|
+
sourceDomain: zod.z.number().int().nonnegative(),
|
|
11416
|
+
abiSignature: zod.z.string().min(1),
|
|
11417
|
+
args: zod.z.array(zod.z.union([
|
|
11418
|
+
zod.z.string(),
|
|
11419
|
+
zod.z.array(zod.z.string())
|
|
11420
|
+
])),
|
|
11421
|
+
isTestnet: zod.z.boolean(),
|
|
11422
|
+
baseUrl: httpsUrlSchema.optional(),
|
|
11423
|
+
config: apiPollingConfigSchema.optional()
|
|
11424
|
+
}).strict();
|
|
11425
|
+
const quoteExpiryStatusSchema = zod.z.discriminatedUnion('mode', [
|
|
11426
|
+
zod.z.object({
|
|
11427
|
+
mode: zod.z.literal('TIMESTAMP'),
|
|
11428
|
+
expired: zod.z.boolean(),
|
|
11429
|
+
secondsRemaining: zod.z.number().int().nonnegative(),
|
|
11430
|
+
expiresAt: zod.z.number().int().nonnegative()
|
|
11431
|
+
}).passthrough(),
|
|
11432
|
+
zod.z.object({
|
|
11433
|
+
mode: zod.z.literal('BLOCK_NUMBER'),
|
|
11434
|
+
expired: zod.z.boolean(),
|
|
11435
|
+
secondsRemaining: zod.z.number().int().nonnegative(),
|
|
11436
|
+
expiresAtBlock: zod.z.number().int().nonnegative(),
|
|
11437
|
+
blockEstimatedAt: zod.z.number().int().nonnegative().optional()
|
|
11438
|
+
}).passthrough()
|
|
11439
|
+
]);
|
|
11440
|
+
const validateQuoteItemSchema = zod.z.object({
|
|
11441
|
+
type: zod.z.string().min(1),
|
|
11442
|
+
argsMatch: zod.z.boolean(),
|
|
11443
|
+
amount: numericStringSchema.optional(),
|
|
11444
|
+
args: zod.z.array(zod.z.string()).optional(),
|
|
11445
|
+
argsHash: bytes32Schema.optional(),
|
|
11446
|
+
computedArgsHash: bytes32Schema.optional()
|
|
11447
|
+
}).passthrough();
|
|
11448
|
+
/**
|
|
11449
|
+
* Schema for a response from the Quote API validation endpoint.
|
|
11450
|
+
*
|
|
11451
|
+
* The endpoint takes the source domain as a URL path parameter and does not
|
|
11452
|
+
* return it in the response body, so `sourceDomain` is intentionally not part
|
|
11453
|
+
* of this schema.
|
|
11454
|
+
*/ zod.z.object({
|
|
11455
|
+
signedQuote: nonEmptyHexSchema,
|
|
11456
|
+
expiry: quoteExpiryStatusSchema,
|
|
11457
|
+
feeTotalAmount: numericStringSchema,
|
|
11458
|
+
feeToken: evmAddressSchema,
|
|
11459
|
+
nonce: numericStringSchema,
|
|
11460
|
+
claimable: zod.z.boolean(),
|
|
11461
|
+
// Preserve newly introduced server-side reasons as opaque strings rather
|
|
11462
|
+
// than rejecting the entire safety response before the SDK is updated.
|
|
11463
|
+
failedChecks: zod.z.array(zod.z.string().min(1)),
|
|
11464
|
+
items: zod.z.array(validateQuoteItemSchema)
|
|
11465
|
+
}).passthrough();
|
|
11466
|
+
|
|
10981
11467
|
/** SDK name used in telemetry payloads. */ resolveKitSdkName(pkg$2.name);
|
|
10982
11468
|
|
|
10983
11469
|
// Auto-register this kit for user agent tracking
|
|
10984
11470
|
registerKit(`${pkg$2.name}/${pkg$2.version}`);
|
|
10985
11471
|
|
|
10986
11472
|
var name$1 = "@circle-fin/swap-kit";
|
|
10987
|
-
var version$1 = "1.
|
|
11473
|
+
var version$1 = "1.6.0";
|
|
10988
11474
|
var pkg$1 = {
|
|
10989
11475
|
name: name$1,
|
|
10990
11476
|
version: version$1};
|
|
@@ -10998,7 +11484,7 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
10998
11484
|
* Catches obviously malformed addresses at parse time; chain-specific validation
|
|
10999
11485
|
* is performed in buildServiceParams.
|
|
11000
11486
|
*/ const destinationAddressSchema = zod.z.union([
|
|
11001
|
-
evmAddressSchema,
|
|
11487
|
+
evmAddressSchema$1,
|
|
11002
11488
|
solanaAddressSchema
|
|
11003
11489
|
]);
|
|
11004
11490
|
/**
|
|
@@ -11044,9 +11530,16 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
11044
11530
|
message: 'stopLimit must be greater than 0'
|
|
11045
11531
|
}).optional(),
|
|
11046
11532
|
customFee: serviceSwapCustomFeeSchema.optional(),
|
|
11533
|
+
apiKey: zod.z.string({
|
|
11534
|
+
invalid_type_error: 'apiKey must be a string'
|
|
11535
|
+
})// Tolerate '' so the `process.env.CIRCLE_API_KEY ?? ''` idiom falls back to
|
|
11536
|
+
// kitKey via resolveApiKey instead of being rejected here.
|
|
11537
|
+
.optional(),
|
|
11047
11538
|
kitKey: zod.z.string({
|
|
11048
11539
|
invalid_type_error: 'kitKey must be a string'
|
|
11049
|
-
})
|
|
11540
|
+
})// Tolerate '' so an unset kit-key env var yields the permissionless path,
|
|
11541
|
+
// matching buildServiceParams (which already omits an empty credential).
|
|
11542
|
+
.optional(),
|
|
11050
11543
|
provider: zod.z.string({
|
|
11051
11544
|
invalid_type_error: 'provider must be a string'
|
|
11052
11545
|
}).min(1, 'provider must be a non-empty string').optional(),
|
|
@@ -11211,23 +11704,49 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
11211
11704
|
fees: zod.z.array(serviceSwapFeeSchema).optional()
|
|
11212
11705
|
}).passthrough();
|
|
11213
11706
|
|
|
11214
|
-
/** Placeholder used wherever a
|
|
11707
|
+
/** Placeholder used wherever a credential is scrubbed from logs, traces, or errors. */ const REDACTED_CREDENTIAL = '[redacted]';
|
|
11708
|
+
/**
|
|
11709
|
+
* Config fields that carry a Stablecoin Service credential.
|
|
11710
|
+
*
|
|
11711
|
+
* `apiKey` is the supported field; `kitKey` is the deprecated alias. Redaction
|
|
11712
|
+
* and credential resolution both read this list so a newly added field is
|
|
11713
|
+
* scrubbed everywhere it needs to be.
|
|
11714
|
+
*/ const CREDENTIAL_CONFIG_FIELDS = [
|
|
11715
|
+
'apiKey',
|
|
11716
|
+
'kitKey'
|
|
11717
|
+
];
|
|
11215
11718
|
|
|
11719
|
+
/**
|
|
11720
|
+
* Replaces any credential field present on a config with a redaction marker.
|
|
11721
|
+
*
|
|
11722
|
+
* Covers `apiKey` and the deprecated `kitKey`, so adding a credential field
|
|
11723
|
+
* without extending this list cannot silently leak it into a trace. Returns the
|
|
11724
|
+
* config unchanged when it carries no credential.
|
|
11725
|
+
*/ const redactCredentialFields = (config)=>{
|
|
11726
|
+
const present = CREDENTIAL_CONFIG_FIELDS.filter((field)=>field in config);
|
|
11727
|
+
if (present.length === 0) {
|
|
11728
|
+
return config;
|
|
11729
|
+
}
|
|
11730
|
+
return present.reduce((acc, field)=>({
|
|
11731
|
+
...acc,
|
|
11732
|
+
[field]: REDACTED_CREDENTIAL
|
|
11733
|
+
}), {
|
|
11734
|
+
...config
|
|
11735
|
+
});
|
|
11736
|
+
};
|
|
11216
11737
|
/**
|
|
11217
11738
|
* Builds a redacted projection of swap params that is safe to embed in error
|
|
11218
11739
|
* traces (which may be logged downstream). Allow-lists only non-sensitive
|
|
11219
11740
|
* fields and drops `from` entirely — `from.adapter` can carry signer/private-key
|
|
11220
|
-
* material for signer-backed (viem/ethers) flows — and redacts
|
|
11741
|
+
* material for signer-backed (viem/ethers) flows — and redacts every credential
|
|
11742
|
+
* field on `config`.
|
|
11221
11743
|
*/ const redactSwapParamsForTrace = (params)=>{
|
|
11222
11744
|
if (typeof params !== 'object' || params === null) {
|
|
11223
11745
|
return params;
|
|
11224
11746
|
}
|
|
11225
11747
|
const record = params;
|
|
11226
11748
|
const config = record['config'];
|
|
11227
|
-
const redactedConfig = typeof config === 'object' && config !== null
|
|
11228
|
-
...config,
|
|
11229
|
-
kitKey: REDACTED_KIT_KEY
|
|
11230
|
-
} : config;
|
|
11749
|
+
const redactedConfig = typeof config === 'object' && config !== null ? redactCredentialFields(config) : config;
|
|
11231
11750
|
return {
|
|
11232
11751
|
tokenIn: record['tokenIn'],
|
|
11233
11752
|
tokenOut: record['tokenOut'],
|
|
@@ -11311,6 +11830,41 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
11311
11830
|
*
|
|
11312
11831
|
* @internal
|
|
11313
11832
|
*/ const MAX_RATE_ADDRESSES_PER_REQUEST = 100;
|
|
11833
|
+
/**
|
|
11834
|
+
* Environment prefixes carried by Circle platform API keys.
|
|
11835
|
+
*
|
|
11836
|
+
* A Circle API key is `<ENV>_API_KEY:<keyId>:<keySecret>`, where `<ENV>` is one
|
|
11837
|
+
* of these prefixes.
|
|
11838
|
+
*
|
|
11839
|
+
* @internal
|
|
11840
|
+
*/ const API_KEY_ENV_PREFIXES = [
|
|
11841
|
+
'TEST',
|
|
11842
|
+
'LIVE',
|
|
11843
|
+
'SAND',
|
|
11844
|
+
'SANDBOX',
|
|
11845
|
+
'SMOK',
|
|
11846
|
+
'PROD',
|
|
11847
|
+
'STAG',
|
|
11848
|
+
'DEV'
|
|
11849
|
+
];
|
|
11850
|
+
/**
|
|
11851
|
+
* Accepted credential formats for Stablecoin Service authentication.
|
|
11852
|
+
*
|
|
11853
|
+
* Matches a Circle platform API key (`<ENV>_API_KEY:<keyId>:<keySecret>`) and
|
|
11854
|
+
* the legacy kit key (`KIT_KEY:<keyId>:<keySecret>`). API keys are the
|
|
11855
|
+
* recommended credential; kit keys remain accepted as the legacy path.
|
|
11856
|
+
*
|
|
11857
|
+
* @remarks
|
|
11858
|
+
* This is a local pre-flight check, not the authority — the Stablecoin Service
|
|
11859
|
+
* validates the credential and answers 401 when it rejects one. The prefix list
|
|
11860
|
+
* is therefore deliberately permissive: a valid key carrying a prefix this SDK
|
|
11861
|
+
* has not been taught about should reach the service and be judged there rather
|
|
11862
|
+
* than be refused locally, since refusing locally is indistinguishable from an
|
|
11863
|
+
* outage to the caller. Kept as the single source of truth so the pattern is
|
|
11864
|
+
* not restated per call site.
|
|
11865
|
+
*
|
|
11866
|
+
* @internal
|
|
11867
|
+
*/ const API_KEY_PATTERN = new RegExp(`^(?:KIT_KEY|(?:${API_KEY_ENV_PREFIXES.join('|')})_API_KEY)` + ':[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+$');
|
|
11314
11868
|
|
|
11315
11869
|
/**
|
|
11316
11870
|
* Zod schema for validating stop limits.
|
|
@@ -11379,13 +11933,14 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
11379
11933
|
/**
|
|
11380
11934
|
* Zod schema for validating API keys.
|
|
11381
11935
|
*
|
|
11382
|
-
*
|
|
11936
|
+
* Accepts a Circle platform API key (`<ENV>_API_KEY:<keyId>:<keySecret>`) and
|
|
11937
|
+
* the legacy kit key (`KIT_KEY:<keyId>:<keySecret>`).
|
|
11383
11938
|
*
|
|
11384
11939
|
* @example
|
|
11385
11940
|
* ```typescript
|
|
11386
11941
|
* import { apiKeySchema } from '@core/service-client'
|
|
11387
11942
|
*
|
|
11388
|
-
* const result = apiKeySchema.safeParse('
|
|
11943
|
+
* const result = apiKeySchema.safeParse('TEST_API_KEY:e84d2546d4e321b2ff427dc988c89503:f84d2548d4e322b2ff427fc989c87503')
|
|
11389
11944
|
* if (!result.success) {
|
|
11390
11945
|
* console.error('Invalid API key format:', result.error.issues)
|
|
11391
11946
|
* }
|
|
@@ -11393,7 +11948,7 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
|
|
|
11393
11948
|
*/ const apiKeySchema = zod.z.string({
|
|
11394
11949
|
required_error: 'API key is required',
|
|
11395
11950
|
invalid_type_error: 'Invalid API key format'
|
|
11396
|
-
}).regex(
|
|
11951
|
+
}).regex(API_KEY_PATTERN, 'Invalid API key format');
|
|
11397
11952
|
/**
|
|
11398
11953
|
* Zod schema for platform fees configuration.
|
|
11399
11954
|
*
|
|
@@ -11914,21 +12469,55 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
11914
12469
|
* ```
|
|
11915
12470
|
*/ const isGetTokenRatesResponse = (obj)=>getTokenRatesResponseSchema.safeParse(obj).success;
|
|
11916
12471
|
/**
|
|
11917
|
-
*
|
|
12472
|
+
* Resolve the credential to authenticate a Stablecoin Service request with.
|
|
12473
|
+
*
|
|
12474
|
+
* `apiKey` is the supported field; `kitKey` is the deprecated alias kept for
|
|
12475
|
+
* existing integrations. When both are supplied `apiKey` wins, so a caller
|
|
12476
|
+
* migrating field-by-field cannot be silently pinned to a stale credential.
|
|
12477
|
+
*
|
|
12478
|
+
* An empty-string value is treated as absent on either field. Without this, the
|
|
12479
|
+
* common `process.env.CIRCLE_API_KEY ?? ''` idiom (which yields `''` when the
|
|
12480
|
+
* variable is unset) would either shadow a working `kitKey` or, on a bare
|
|
12481
|
+
* `kitKey: ''`, reach downstream validation as an invalid credential instead of
|
|
12482
|
+
* falling through to the permissionless path.
|
|
12483
|
+
*
|
|
12484
|
+
* @param source - Object carrying either credential field, or neither.
|
|
12485
|
+
* @returns The credential to use, or `undefined` for the permissionless
|
|
12486
|
+
* (keyless) path.
|
|
12487
|
+
*
|
|
12488
|
+
* @example
|
|
12489
|
+
* ```typescript
|
|
12490
|
+
* import { resolveApiKey } from '@core/service-client'
|
|
12491
|
+
*
|
|
12492
|
+
* resolveApiKey({ apiKey: 'TEST_API_KEY:id:secret' }) // 'TEST_API_KEY:id:secret'
|
|
12493
|
+
* resolveApiKey({ kitKey: 'KIT_KEY:id:secret' }) // 'KIT_KEY:id:secret'
|
|
12494
|
+
* resolveApiKey({ apiKey: '', kitKey: 'KIT_KEY:id:secret' }) // 'KIT_KEY:id:secret'
|
|
12495
|
+
* resolveApiKey({ kitKey: '' }) // undefined
|
|
12496
|
+
* resolveApiKey({}) // undefined
|
|
12497
|
+
* ```
|
|
12498
|
+
*/ const resolveApiKey = (source)=>{
|
|
12499
|
+
// Treat an empty-string value as absent on either field so the
|
|
12500
|
+
// `env ?? ''` idiom falls through to the next credential (or permissionless).
|
|
12501
|
+
const normalize = (value)=>value !== undefined && value !== '' ? value : undefined;
|
|
12502
|
+
return normalize(source.apiKey) ?? normalize(source.kitKey);
|
|
12503
|
+
};
|
|
12504
|
+
/**
|
|
12505
|
+
* Assert that a Stablecoin Service credential is not supplied from a browser.
|
|
11918
12506
|
*
|
|
11919
|
-
*
|
|
11920
|
-
*
|
|
11921
|
-
*
|
|
11922
|
-
*
|
|
11923
|
-
*
|
|
11924
|
-
*
|
|
11925
|
-
*
|
|
11926
|
-
*
|
|
12507
|
+
* An API key (`<ENV>_API_KEY:<id>:<secret>`) and a legacy kit key
|
|
12508
|
+
* (`KIT_KEY:<id>:<secret>`) are both server-only secrets. Every Stablecoin
|
|
12509
|
+
* Service request that attaches an `Authorization: Bearer` header funnels
|
|
12510
|
+
* through this package, so calling this guard before that header is built
|
|
12511
|
+
* prevents the secret from being sent from — and thus bundled into — a client
|
|
12512
|
+
* application. In Node.js the check is a no-op, preserving the legitimate "hold
|
|
12513
|
+
* the credential on the server, forward the prepared transaction to the client"
|
|
12514
|
+
* flow. When no credential is supplied the permissionless (keyless) client path
|
|
12515
|
+
* remains fully allowed.
|
|
11927
12516
|
*
|
|
11928
|
-
* @param apiKey - The inline
|
|
11929
|
-
* was supplied (permissionless mode).
|
|
12517
|
+
* @param apiKey - The inline credential for the request, or `undefined` when
|
|
12518
|
+
* none was supplied (permissionless mode).
|
|
11930
12519
|
* @returns Nothing.
|
|
11931
|
-
* @throws KitError with VALIDATION_FAILED when a
|
|
12520
|
+
* @throws KitError with VALIDATION_FAILED when a credential is supplied while
|
|
11932
12521
|
* running in a browser environment. The secret value is never echoed.
|
|
11933
12522
|
*
|
|
11934
12523
|
* @example
|
|
@@ -11936,10 +12525,10 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
11936
12525
|
* import { assertBrowserSafeApiKey } from '@core/service-client'
|
|
11937
12526
|
*
|
|
11938
12527
|
* // Server (Node.js): no-op, request proceeds with the Authorization header.
|
|
11939
|
-
* assertBrowserSafeApiKey('
|
|
12528
|
+
* assertBrowserSafeApiKey('TEST_API_KEY:my-id:my-secret')
|
|
11940
12529
|
*
|
|
11941
12530
|
* // Browser: throws to stop the secret from leaking into the client bundle.
|
|
11942
|
-
* assertBrowserSafeApiKey('
|
|
12531
|
+
* assertBrowserSafeApiKey('TEST_API_KEY:my-id:my-secret')
|
|
11943
12532
|
*
|
|
11944
12533
|
* // Browser, permissionless: allowed.
|
|
11945
12534
|
* assertBrowserSafeApiKey(undefined)
|
|
@@ -11949,7 +12538,7 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
11949
12538
|
return;
|
|
11950
12539
|
}
|
|
11951
12540
|
if (isBrowserEnvironment()) {
|
|
11952
|
-
throw createValidationFailedError$1('
|
|
12541
|
+
throw createValidationFailedError$1('apiKey', '[redacted]', 'apiKey must not be provided in a browser environment — it is a server-only secret. Run kit operations that use an API key on your server, or omit apiKey (and the legacy kitKey) to use the permissionless (keyless) client path');
|
|
11953
12542
|
}
|
|
11954
12543
|
};
|
|
11955
12544
|
|
|
@@ -11961,7 +12550,8 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
11961
12550
|
*
|
|
11962
12551
|
* @remarks
|
|
11963
12552
|
* - Input validation leverages Zod schemas to surface actionable KitErrors.
|
|
11964
|
-
* - API key format must match
|
|
12553
|
+
* - API key format must match `<ENV>_API_KEY:<keyId>:<keySecret>`, or the
|
|
12554
|
+
* legacy `KIT_KEY:<keyId>:<keySecret>`
|
|
11965
12555
|
*
|
|
11966
12556
|
* @param params - The create transaction request parameters with API key.
|
|
11967
12557
|
* @returns A promise that resolves to a typed {@link CreateSwapResponse}.
|
|
@@ -11990,7 +12580,7 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
11990
12580
|
* recipientAddress: '0x050928e1f9086b20539c767c96909663ff7fbdf2',
|
|
11991
12581
|
* },
|
|
11992
12582
|
* },
|
|
11993
|
-
* apiKey: '
|
|
12583
|
+
* apiKey: 'TEST_API_KEY:example-key:example-secret',
|
|
11994
12584
|
* })
|
|
11995
12585
|
*
|
|
11996
12586
|
* console.log(`Transaction target: ${transaction.transaction.target}`)
|
|
@@ -12009,13 +12599,13 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12009
12599
|
const url = new URL('/v1/stablecoinKits/swap', STABLECOIN_SERVICE_BASE_URL).toString();
|
|
12010
12600
|
// Remove the API key from the request body
|
|
12011
12601
|
const { apiKey, ...requestBody } = validatedParams;
|
|
12012
|
-
// Never let a server-only
|
|
12602
|
+
// Never let a server-only credential leave a browser (no-op in Node.js).
|
|
12013
12603
|
assertBrowserSafeApiKey(apiKey);
|
|
12014
12604
|
const effectiveConfig = {
|
|
12015
12605
|
...DEFAULT_CONFIG,
|
|
12016
12606
|
headers: {
|
|
12017
12607
|
...DEFAULT_CONFIG.headers,
|
|
12018
|
-
// Permissionless mode: no Authorization header when the
|
|
12608
|
+
// Permissionless mode: no Authorization header when the credential is absent.
|
|
12019
12609
|
...apiKey !== undefined && {
|
|
12020
12610
|
Authorization: `Bearer ${apiKey}`
|
|
12021
12611
|
}
|
|
@@ -12165,7 +12755,7 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12165
12755
|
}
|
|
12166
12756
|
// Use validated data
|
|
12167
12757
|
const validatedParams = result.data;
|
|
12168
|
-
// Never let a server-only
|
|
12758
|
+
// Never let a server-only credential leave a browser (no-op in Node.js).
|
|
12169
12759
|
assertBrowserSafeApiKey(validatedParams.apiKey);
|
|
12170
12760
|
// Build the API URL
|
|
12171
12761
|
const url = buildQuoteUrl(validatedParams);
|
|
@@ -12174,7 +12764,7 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12174
12764
|
...DEFAULT_CONFIG,
|
|
12175
12765
|
headers: {
|
|
12176
12766
|
...DEFAULT_CONFIG.headers,
|
|
12177
|
-
// Permissionless mode: no Authorization header when the
|
|
12767
|
+
// Permissionless mode: no Authorization header when the credential is absent.
|
|
12178
12768
|
...validatedParams.apiKey !== undefined && {
|
|
12179
12769
|
Authorization: `Bearer ${validatedParams.apiKey}`
|
|
12180
12770
|
}
|
|
@@ -12239,14 +12829,14 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12239
12829
|
toChain: result.data.toChain
|
|
12240
12830
|
}
|
|
12241
12831
|
};
|
|
12242
|
-
// Never let a server-only
|
|
12832
|
+
// Never let a server-only credential leave a browser (no-op in Node.js).
|
|
12243
12833
|
assertBrowserSafeApiKey(validatedParams.apiKey);
|
|
12244
12834
|
const url = buildSwapStatusUrl(validatedParams);
|
|
12245
12835
|
const effectiveConfig = {
|
|
12246
12836
|
...DEFAULT_CONFIG,
|
|
12247
12837
|
headers: {
|
|
12248
12838
|
...DEFAULT_CONFIG.headers,
|
|
12249
|
-
// Permissionless mode: no Authorization header when the
|
|
12839
|
+
// Permissionless mode: no Authorization header when the credential is absent.
|
|
12250
12840
|
...validatedParams.apiKey !== undefined && {
|
|
12251
12841
|
Authorization: `Bearer ${validatedParams.apiKey}`
|
|
12252
12842
|
}
|
|
@@ -12272,7 +12862,7 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12272
12862
|
* const url = buildTokenRatesUrl({
|
|
12273
12863
|
* chain: 'Ethereum',
|
|
12274
12864
|
* addresses: ['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'],
|
|
12275
|
-
* apiKey: '
|
|
12865
|
+
* apiKey: 'TEST_API_KEY:key:secret',
|
|
12276
12866
|
* })
|
|
12277
12867
|
* // => 'https://api.circle.com/v1/stablecoinKits/rates?chain=Ethereum&addresses=...'
|
|
12278
12868
|
* ```
|
|
@@ -12345,14 +12935,14 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
|
|
|
12345
12935
|
addresses: result.data.addresses
|
|
12346
12936
|
}
|
|
12347
12937
|
};
|
|
12348
|
-
// Never let a server-only
|
|
12938
|
+
// Never let a server-only credential leave a browser (no-op in Node.js).
|
|
12349
12939
|
assertBrowserSafeApiKey(validatedParams.apiKey);
|
|
12350
12940
|
const url = buildTokenRatesUrl(validatedParams);
|
|
12351
12941
|
const effectiveConfig = {
|
|
12352
12942
|
...DEFAULT_CONFIG,
|
|
12353
12943
|
headers: {
|
|
12354
12944
|
...DEFAULT_CONFIG.headers,
|
|
12355
|
-
// Permissionless mode: no Authorization header when the
|
|
12945
|
+
// Permissionless mode: no Authorization header when the credential is absent.
|
|
12356
12946
|
...validatedParams.apiKey !== undefined && {
|
|
12357
12947
|
Authorization: `Bearer ${validatedParams.apiKey}`
|
|
12358
12948
|
}
|
|
@@ -12790,7 +13380,7 @@ const abiParameterSchema = zod.z.object({
|
|
|
12790
13380
|
*/ zod.z.object({
|
|
12791
13381
|
type: zod.z.literal('evm'),
|
|
12792
13382
|
abi: abiSchema,
|
|
12793
|
-
address: evmAddressSchema,
|
|
13383
|
+
address: evmAddressSchema$1,
|
|
12794
13384
|
functionName: zod.z.string({
|
|
12795
13385
|
required_error: 'Function name is required',
|
|
12796
13386
|
invalid_type_error: 'Function name must be a string'
|
|
@@ -12827,7 +13417,7 @@ const abiParameterSchema = zod.z.object({
|
|
|
12827
13417
|
* }
|
|
12828
13418
|
* ```
|
|
12829
13419
|
*/ zod.z.object({
|
|
12830
|
-
address: evmAddressSchema,
|
|
13420
|
+
address: evmAddressSchema$1,
|
|
12831
13421
|
value: zod.z.bigint({
|
|
12832
13422
|
required_error: 'Value is required for native transfers',
|
|
12833
13423
|
invalid_type_error: 'Value must be a bigint'
|
|
@@ -13359,7 +13949,7 @@ zod.z.object({
|
|
|
13359
13949
|
signature: evmSignatureSchema,
|
|
13360
13950
|
tokenInputs: zod.z.array(zod.z.object({
|
|
13361
13951
|
permitType: zod.z.nativeEnum(PermitType),
|
|
13362
|
-
token: evmAddressSchema,
|
|
13952
|
+
token: evmAddressSchema$1,
|
|
13363
13953
|
amount: zod.z.bigint().refine((value)=>value >= 0n, {
|
|
13364
13954
|
message: 'amount must be a non-negative bigint'
|
|
13365
13955
|
}),
|
|
@@ -13620,7 +14210,7 @@ enc.encode('used_transfer_spec_hash');
|
|
|
13620
14210
|
});
|
|
13621
14211
|
|
|
13622
14212
|
/**
|
|
13623
|
-
* Assert that the
|
|
14213
|
+
* Assert that the credential is valid for swap operations.
|
|
13624
14214
|
*
|
|
13625
14215
|
* @remarks
|
|
13626
14216
|
* This validation is called when swap operations are executed, not at construction time.
|
|
@@ -13628,34 +14218,35 @@ enc.encode('used_transfer_spec_hash');
|
|
|
13628
14218
|
* at usage time rather than construction time.
|
|
13629
14219
|
*
|
|
13630
14220
|
* Validates:
|
|
13631
|
-
* -
|
|
13632
|
-
*
|
|
13633
|
-
*
|
|
14221
|
+
* - The credential matches an accepted format when provided — a Circle API key
|
|
14222
|
+
* (`<ENV>_API_KEY:id:secret`) or a legacy kit key (`KIT_KEY:id:secret`).
|
|
14223
|
+
* An absent or empty credential is permitted (permissionless mode) — the swap
|
|
14224
|
+
* service treats the credential as optional.
|
|
13634
14225
|
*
|
|
13635
|
-
* @param
|
|
13636
|
-
* @throws KitError with VALIDATION_FAILED if a
|
|
13637
|
-
* match
|
|
14226
|
+
* @param apiKey - The inline credential from the swap operation config (optional)
|
|
14227
|
+
* @throws KitError with VALIDATION_FAILED if a credential is provided but does
|
|
14228
|
+
* not match an accepted format
|
|
13638
14229
|
*
|
|
13639
14230
|
* @example
|
|
13640
14231
|
* ```typescript
|
|
13641
|
-
* import {
|
|
14232
|
+
* import { assertApiKey } from './assertApiKey'
|
|
13642
14233
|
*
|
|
13643
|
-
* const
|
|
14234
|
+
* const apiKey = 'TEST_API_KEY:9d1bd085-bad2-4a2b-ae67-5814b85167c9:secretvalue'
|
|
13644
14235
|
*
|
|
13645
|
-
* // Validate
|
|
13646
|
-
*
|
|
14236
|
+
* // Validate the credential before use
|
|
14237
|
+
* assertApiKey(apiKey)
|
|
13647
14238
|
* ```
|
|
13648
|
-
*/ function
|
|
13649
|
-
// Permissionless mode: the swap service treats the
|
|
13650
|
-
// absent (or empty)
|
|
14239
|
+
*/ function assertApiKey(apiKey) {
|
|
14240
|
+
// Permissionless mode: the swap service treats the credential as optional, so
|
|
14241
|
+
// an absent (or empty) value is valid. Only validate the format when one is
|
|
13651
14242
|
// actually provided.
|
|
13652
|
-
if (!
|
|
14243
|
+
if (!apiKey) {
|
|
13653
14244
|
return;
|
|
13654
14245
|
}
|
|
13655
|
-
const apiKeyResult = apiKeySchema.safeParse(
|
|
14246
|
+
const apiKeyResult = apiKeySchema.safeParse(apiKey);
|
|
13656
14247
|
if (!apiKeyResult.success) {
|
|
13657
14248
|
const errors = apiKeyResult.error.issues.map((issue)=>issue.message).join(', ');
|
|
13658
|
-
throw createValidationFailedError$1('
|
|
14249
|
+
throw createValidationFailedError$1('apiKey', REDACTED_CREDENTIAL, `Invalid API key format. ${errors}. Expected format: <ENV>_API_KEY:<keyId>:<keySecret> (for example TEST_API_KEY:... or LIVE_API_KEY:...). Legacy KIT_KEY:<keyId>:<keySecret> values are still accepted. Get your key at: https://developers.circle.com/w3s/keys`);
|
|
13659
14250
|
}
|
|
13660
14251
|
}
|
|
13661
14252
|
|
|
@@ -13847,7 +14438,7 @@ const TOKEN_REGISTRY$3 = createTokenRegistry();
|
|
|
13847
14438
|
}
|
|
13848
14439
|
// Validate recipient address format matches the chain type
|
|
13849
14440
|
if (chain.type === 'evm') {
|
|
13850
|
-
const result = evmAddressSchema.safeParse(recipientAddress);
|
|
14441
|
+
const result = evmAddressSchema$1.safeParse(recipientAddress);
|
|
13851
14442
|
if (!result.success) {
|
|
13852
14443
|
throw createInvalidAddressError(recipientAddress, chain.name, '0x-prefixed 42-character hex string (0x + 40 hex characters)');
|
|
13853
14444
|
}
|
|
@@ -13909,7 +14500,7 @@ function resolveFeePayoutChain(tokenIn, tokenOut, sourceChain, destinationChain)
|
|
|
13909
14500
|
* to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
|
|
13910
14501
|
* config: {
|
|
13911
14502
|
* slippageBps: 300,
|
|
13912
|
-
*
|
|
14503
|
+
* apiKey: 'TEST_API_KEY:...:...' // Inline credential (optional)
|
|
13913
14504
|
* }
|
|
13914
14505
|
* }
|
|
13915
14506
|
*
|
|
@@ -13947,18 +14538,17 @@ function resolveFeePayoutChain(tokenIn, tokenOut, sourceChain, destinationChain)
|
|
|
13947
14538
|
validateResolvedAddress(resolvedTokenInAddress, chain);
|
|
13948
14539
|
validateResolvedAddress(resolvedTokenOutAddress, destinationChain);
|
|
13949
14540
|
validateResolvedAddress(to, destinationChain);
|
|
13950
|
-
const
|
|
13951
|
-
// Validate the
|
|
13952
|
-
|
|
14541
|
+
const apiKey = resolveApiKey(config ?? {});
|
|
14542
|
+
// Validate the credential format when one is provided (permissionless
|
|
14543
|
+
// otherwise).
|
|
14544
|
+
assertApiKey(apiKey);
|
|
13953
14545
|
// Validate custom fee configuration if present
|
|
13954
14546
|
const customFee = config?.customFee;
|
|
13955
14547
|
if (customFee !== undefined) {
|
|
13956
14548
|
const feePayoutChain = resolveFeePayoutChain(tokenIn, tokenOut, chain, destinationChain);
|
|
13957
14549
|
validateCustomFeeConfig(customFee, feePayoutChain);
|
|
13958
14550
|
}
|
|
13959
|
-
// Build CreateSwapParams for service client
|
|
13960
|
-
// Use object spread to conditionally include optional properties
|
|
13961
|
-
// Note: Service client expects 'apiKey' field, so we map kitKey → apiKey
|
|
14551
|
+
// Build CreateSwapParams for service client, spreading optional properties.
|
|
13962
14552
|
const chainName = chain.chain // The API expects the Blockchain enum value format like "World_Chain"
|
|
13963
14553
|
;
|
|
13964
14554
|
const destinationChainName = destinationChain.chain;
|
|
@@ -13993,9 +14583,9 @@ function resolveFeePayoutChain(tokenIn, tokenOut, sourceChain, destinationChain)
|
|
|
13993
14583
|
}
|
|
13994
14584
|
}
|
|
13995
14585
|
},
|
|
13996
|
-
//
|
|
13997
|
-
...
|
|
13998
|
-
apiKey
|
|
14586
|
+
// Omitted in permissionless mode.
|
|
14587
|
+
...apiKey ? {
|
|
14588
|
+
apiKey
|
|
13999
14589
|
} : {}
|
|
14000
14590
|
};
|
|
14001
14591
|
}
|
|
@@ -15304,14 +15894,13 @@ const TOKEN_REGISTRY$2 = createTokenRegistry();
|
|
|
15304
15894
|
return;
|
|
15305
15895
|
}
|
|
15306
15896
|
// For non-native tokens (SPL tokens, ERC-20 tokens), check the token balance
|
|
15307
|
-
const
|
|
15897
|
+
const balance = await executeAdapterReadAction(adapter, 'token.balanceOf', {
|
|
15308
15898
|
tokenAddress: tokenInAddress,
|
|
15309
15899
|
walletAddress
|
|
15310
15900
|
}, context);
|
|
15311
|
-
const balance = await balancePrepared.execute();
|
|
15312
15901
|
// Compare balances
|
|
15313
15902
|
const requiredAmount = BigInt(amount);
|
|
15314
|
-
const currentBalance = BigInt(balance);
|
|
15903
|
+
const currentBalance = BigInt(String(balance));
|
|
15315
15904
|
if (currentBalance < requiredAmount) {
|
|
15316
15905
|
throw new KitError({
|
|
15317
15906
|
...BalanceError.INSUFFICIENT_TOKEN,
|
|
@@ -15900,9 +16489,9 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
|
|
|
15900
16489
|
* ```typescript
|
|
15901
16490
|
* import { StablecoinServiceSwapProvider } from '@circle-fin/provider-stablecoin-service-swap'
|
|
15902
16491
|
*
|
|
15903
|
-
* // Create provider with developer fee (1 USDC)
|
|
16492
|
+
* // Create provider with developer fee (1 USDC).
|
|
16493
|
+
* // Credentials are supplied per operation via `config.apiKey`, not here.
|
|
15904
16494
|
* const provider = new StablecoinServiceSwapProvider({
|
|
15905
|
-
* kitKey: process.env.STABLECOIN_KIT_API_KEY,
|
|
15906
16495
|
* customFee: {
|
|
15907
16496
|
* amount: '1000000', // 1 USDC in base units (6 decimals)
|
|
15908
16497
|
* recipientAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0'
|
|
@@ -16472,11 +17061,10 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
|
|
|
16472
17061
|
* @throws Error if the adapter fails to prepare or execute approval transactions
|
|
16473
17062
|
* @throws Error if transaction confirmation fails or times out
|
|
16474
17063
|
*/ async handleUsdtApproval(adapter, chain, executionCtx, adapterContractAddress, resolvedContext, executedTransactions) {
|
|
16475
|
-
const
|
|
17064
|
+
const current = await readTokenAllowance(adapter, {
|
|
16476
17065
|
tokenAddress: executionCtx.tokenInAddress,
|
|
16477
17066
|
delegate: adapterContractAddress
|
|
16478
17067
|
}, resolvedContext);
|
|
16479
|
-
const current = BigInt(await allowanceRequest.execute());
|
|
16480
17068
|
const required = BigInt(executionCtx.amount);
|
|
16481
17069
|
if (current >= required) {
|
|
16482
17070
|
// Sufficient allowance - proceed to swap
|
|
@@ -16565,9 +17153,7 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
|
|
|
16565
17153
|
* import { createAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
|
|
16566
17154
|
* import { Ethereum } from '@core/chains'
|
|
16567
17155
|
*
|
|
16568
|
-
* const provider = new StablecoinServiceSwapProvider(
|
|
16569
|
-
* kitKey: process.env.STABLECOIN_KIT_API_KEY
|
|
16570
|
-
* })
|
|
17156
|
+
* const provider = new StablecoinServiceSwapProvider()
|
|
16571
17157
|
*
|
|
16572
17158
|
* const adapter = createAdapterFromPrivateKey({
|
|
16573
17159
|
* privateKey: process.env.PRIVATE_KEY
|
|
@@ -17061,7 +17647,7 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
|
|
|
17061
17647
|
/**
|
|
17062
17648
|
* Fee recipient address (required).
|
|
17063
17649
|
* Must be a valid EVM address or Solana address.
|
|
17064
|
-
*/ recipientAddress: zod.z.string().refine((value)=>evmAddressSchema.safeParse(value).success || solanaAddressSchema.safeParse(value).success, {
|
|
17650
|
+
*/ recipientAddress: zod.z.string().refine((value)=>evmAddressSchema$1.safeParse(value).success || solanaAddressSchema.safeParse(value).success, {
|
|
17065
17651
|
message: 'recipientAddress must be a valid blockchain address: EVM (0x + 40 hex chars) or Solana (base58, 32-44 chars)'
|
|
17066
17652
|
})
|
|
17067
17653
|
}).strict();
|
|
@@ -17073,7 +17659,8 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
|
|
|
17073
17659
|
* - slippageBps: Optional positive number for slippage tolerance
|
|
17074
17660
|
* - stopLimit: Optional decimal string for minimum output
|
|
17075
17661
|
* - customFee: Optional fee configuration
|
|
17076
|
-
* -
|
|
17662
|
+
* - apiKey: Optional credential string
|
|
17663
|
+
* - kitKey: Optional credential string (deprecated alias for apiKey)
|
|
17077
17664
|
*/ const swapConfigSchema = zod.z.object({
|
|
17078
17665
|
allowanceStrategy: allowanceStrategySchema.optional(),
|
|
17079
17666
|
slippageBps: zod.z.number().int().min(0).optional(),
|
|
@@ -17083,11 +17670,12 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
|
|
|
17083
17670
|
attributeName: 'stopLimit'
|
|
17084
17671
|
})(zod.z.string())).optional(),
|
|
17085
17672
|
customFee: swapCustomFeeSchema.optional(),
|
|
17673
|
+
apiKey: zod.z.string().optional(),
|
|
17086
17674
|
kitKey: zod.z.string().optional()
|
|
17087
17675
|
});
|
|
17088
17676
|
const swapDestinationSchema = zod.z.object({
|
|
17089
17677
|
chain: optionalSwapChainIdentifierField,
|
|
17090
|
-
recipientAddress: zod.z.string().refine((value)=>evmAddressSchema.safeParse(value).success || solanaAddressSchema.safeParse(value).success, {
|
|
17678
|
+
recipientAddress: zod.z.string().refine((value)=>evmAddressSchema$1.safeParse(value).success || solanaAddressSchema.safeParse(value).success, {
|
|
17091
17679
|
message: 'recipientAddress must be a valid blockchain address: EVM (0x + 40 hex chars) or Solana (base58, 32-44 chars)'
|
|
17092
17680
|
}).optional()
|
|
17093
17681
|
}).strict();
|
|
@@ -19194,7 +19782,8 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
|
|
|
19194
19782
|
/**
|
|
19195
19783
|
* Helper to format the config section of a swap result, transforming fee amounts.
|
|
19196
19784
|
*
|
|
19197
|
-
* Strips
|
|
19785
|
+
* Strips the credential fields (`apiKey` and the deprecated `kitKey`) from the
|
|
19786
|
+
* config before returning, so a result is safe to log or serialize.
|
|
19198
19787
|
*
|
|
19199
19788
|
* @param config - The swap config from the provider.
|
|
19200
19789
|
* @param outputTokenTransform - The amount transformer for output-token-denominated values (fees and amountOut).
|
|
@@ -19203,11 +19792,11 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
|
|
|
19203
19792
|
if (!config) {
|
|
19204
19793
|
return undefined;
|
|
19205
19794
|
}
|
|
19206
|
-
//
|
|
19207
|
-
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19795
|
+
// Rebuild the config without any credential field. Filtering entries rather
|
|
19796
|
+
// than deleting them avoids reading the deprecated `kitKey` property
|
|
19797
|
+
// directly, and keeps the credential list in one place.
|
|
19798
|
+
const credentialFields = CREDENTIAL_CONFIG_FIELDS;
|
|
19799
|
+
const cloneConfig = Object.fromEntries(Object.entries(config).filter(([key])=>!credentialFields.includes(key)));
|
|
19211
19800
|
if (Object.keys(cloneConfig).length === 0) {
|
|
19212
19801
|
return undefined;
|
|
19213
19802
|
}
|
|
@@ -19408,9 +19997,9 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
|
|
|
19408
19997
|
try {
|
|
19409
19998
|
// Step 1: Build quote params directly (no need for buildServiceParams)
|
|
19410
19999
|
// Use chain.chain (Blockchain enum value like "World_Chain") not chain.name
|
|
19411
|
-
// The
|
|
19412
|
-
// fetched without an Authorization header.
|
|
19413
|
-
const
|
|
20000
|
+
// The credential is optional (permissionless mode); when absent the quote
|
|
20001
|
+
// is fetched without an Authorization header.
|
|
20002
|
+
const apiKey = resolveApiKey(params.config ?? {});
|
|
19414
20003
|
// Resolve token aliases to addresses for the quote API
|
|
19415
20004
|
// The quote endpoint requires resolved addresses, not aliases like 'USDC'
|
|
19416
20005
|
const chain = params.from.chain;
|
|
@@ -19435,8 +20024,8 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
|
|
|
19435
20024
|
...params.config?.slippageBps !== undefined && {
|
|
19436
20025
|
slippageBps: params.config.slippageBps
|
|
19437
20026
|
},
|
|
19438
|
-
...
|
|
19439
|
-
apiKey
|
|
20027
|
+
...apiKey ? {
|
|
20028
|
+
apiKey
|
|
19440
20029
|
} : {}
|
|
19441
20030
|
};
|
|
19442
20031
|
// Step 2: Get quote from service
|
|
@@ -19840,7 +20429,7 @@ const sleep$1 = async (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
|
19840
20429
|
* the service returns `receivingTokenDecimals`. When decimals are missing
|
|
19841
20430
|
* the field is omitted entirely (never raw base units).
|
|
19842
20431
|
*
|
|
19843
|
-
* @param params - `txHash`, `chainIn`, optional `chainOut`, and `
|
|
20432
|
+
* @param params - `txHash`, `chainIn`, optional `chainOut`, and `apiKey`.
|
|
19844
20433
|
* @returns A single snapshot of the swap's status.
|
|
19845
20434
|
* @throws \{KitError\} If `chainIn` or `chainOut` is malformed.
|
|
19846
20435
|
*
|
|
@@ -19856,7 +20445,7 @@ const sleep$1 = async (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
|
19856
20445
|
* txHash: result.txHash,
|
|
19857
20446
|
* chainIn: result.chainIn,
|
|
19858
20447
|
* chainOut: result.chainOut,
|
|
19859
|
-
*
|
|
20448
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
19860
20449
|
* })
|
|
19861
20450
|
* while (status.progress.status === 'PENDING') {
|
|
19862
20451
|
* await new Promise((r) => setTimeout(r, 3_000))
|
|
@@ -19864,7 +20453,7 @@ const sleep$1 = async (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
|
19864
20453
|
* txHash: result.txHash,
|
|
19865
20454
|
* chainIn: result.chainIn,
|
|
19866
20455
|
* chainOut: result.chainOut,
|
|
19867
|
-
*
|
|
20456
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
19868
20457
|
* })
|
|
19869
20458
|
* }
|
|
19870
20459
|
*
|
|
@@ -19882,14 +20471,15 @@ const sleep$1 = async (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
|
19882
20471
|
const chainIn = normalizeChain(params.chainIn, 'chainIn');
|
|
19883
20472
|
const chainOut = params.chainOut === undefined ? undefined : normalizeChain(params.chainOut, 'chainOut');
|
|
19884
20473
|
const isCrossChain = chainOut !== undefined && chainOut !== chainIn;
|
|
20474
|
+
const apiKey = resolveApiKey(params);
|
|
19885
20475
|
const request = {
|
|
19886
20476
|
txHash: params.txHash,
|
|
19887
20477
|
chain: chainIn,
|
|
19888
20478
|
...isCrossChain && {
|
|
19889
20479
|
toChain: chainOut
|
|
19890
20480
|
},
|
|
19891
|
-
...
|
|
19892
|
-
apiKey
|
|
20481
|
+
...apiKey ? {
|
|
20482
|
+
apiKey
|
|
19893
20483
|
} : {}
|
|
19894
20484
|
};
|
|
19895
20485
|
let raw = await getSwapStatus$1(request);
|
|
@@ -19968,9 +20558,9 @@ const isResultShape = (params)=>'result' in params;
|
|
|
19968
20558
|
*
|
|
19969
20559
|
* Two parameter shapes are accepted:
|
|
19970
20560
|
*
|
|
19971
|
-
* - Pass the {@link SwapResult} directly: `{ result,
|
|
20561
|
+
* - Pass the {@link SwapResult} directly: `{ result, apiKey, ... }`.
|
|
19972
20562
|
* Cleanest when chaining off `kit.swap()`.
|
|
19973
|
-
* - Pass discrete fields: `{ txHash, chainIn, chainOut?,
|
|
20563
|
+
* - Pass discrete fields: `{ txHash, chainIn, chainOut?, apiKey, ... }`.
|
|
19974
20564
|
* Useful for resuming an in-flight swap from a persisted record.
|
|
19975
20565
|
*
|
|
19976
20566
|
* @param params - Wait configuration. See {@link WaitForSwapParams}.
|
|
@@ -19990,7 +20580,7 @@ const isResultShape = (params)=>'result' in params;
|
|
|
19990
20580
|
*
|
|
19991
20581
|
* const final = await waitForSwap({
|
|
19992
20582
|
* result,
|
|
19993
|
-
*
|
|
20583
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
19994
20584
|
* onProgress: (snapshot) => {
|
|
19995
20585
|
* console.log(snapshot.progress.substatus ?? snapshot.progress.status)
|
|
19996
20586
|
* },
|
|
@@ -20008,7 +20598,7 @@ const isResultShape = (params)=>'result' in params;
|
|
|
20008
20598
|
* txHash: '0x…',
|
|
20009
20599
|
* chainIn: 'Ethereum',
|
|
20010
20600
|
* chainOut: 'Base',
|
|
20011
|
-
*
|
|
20601
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20012
20602
|
* })
|
|
20013
20603
|
* ```
|
|
20014
20604
|
*/ async function waitForSwap(params) {
|
|
@@ -20024,14 +20614,15 @@ const isResultShape = (params)=>'result' in params;
|
|
|
20024
20614
|
const chainOut = isResultShape(params) ? params.result.chainOut : params.chainOut;
|
|
20025
20615
|
// Delegate parameter validation (txHash, chainIn, chainOut) to
|
|
20026
20616
|
// getSwapStatus so the same rules apply to both helpers.
|
|
20617
|
+
const apiKey = resolveApiKey(params);
|
|
20027
20618
|
const statusParams = {
|
|
20028
20619
|
txHash,
|
|
20029
20620
|
chainIn,
|
|
20030
20621
|
...chainOut !== undefined && {
|
|
20031
20622
|
chainOut
|
|
20032
20623
|
},
|
|
20033
|
-
...
|
|
20034
|
-
|
|
20624
|
+
...apiKey ? {
|
|
20625
|
+
apiKey
|
|
20035
20626
|
} : {}
|
|
20036
20627
|
};
|
|
20037
20628
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -20155,7 +20746,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20155
20746
|
*
|
|
20156
20747
|
* @param context - SwapKit context (provides the `TokenRegistry` used for
|
|
20157
20748
|
* symbol resolution).
|
|
20158
|
-
* @param params - `chain`, optional `tokens`, and `
|
|
20749
|
+
* @param params - `chain`, optional `tokens`, and `apiKey`.
|
|
20159
20750
|
* @returns A nested map of `[chain][address] → { priceUSD, fetchedAt }`.
|
|
20160
20751
|
* @throws \{KitError\} If `chain` cannot be resolved, `tokens` exceeds 100
|
|
20161
20752
|
* entries, or any entry is neither a registered symbol nor a
|
|
@@ -20170,7 +20761,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20170
20761
|
* const { rates } = await getTokenRates(context, {
|
|
20171
20762
|
* chain: Blockchain.Ethereum,
|
|
20172
20763
|
* tokens: ['USDC', 'EURC', 'NATIVE'],
|
|
20173
|
-
*
|
|
20764
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20174
20765
|
* })
|
|
20175
20766
|
*
|
|
20176
20767
|
* const usdc = rates['Ethereum']?.['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48']
|
|
@@ -20191,10 +20782,11 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20191
20782
|
// valid Blockchain enum string, so `getChainByEnum` is guaranteed to resolve.
|
|
20192
20783
|
const chainDef = getChainByEnum(chain);
|
|
20193
20784
|
const resolvedAddresses = params.tokens?.map((entry, index)=>resolveTokenEntry(entry, index, chain, chainDef, context));
|
|
20785
|
+
const apiKey = resolveApiKey(params);
|
|
20194
20786
|
return getTokenRates$1({
|
|
20195
20787
|
chain,
|
|
20196
|
-
...
|
|
20197
|
-
apiKey
|
|
20788
|
+
...apiKey ? {
|
|
20789
|
+
apiKey
|
|
20198
20790
|
} : {},
|
|
20199
20791
|
...resolvedAddresses !== undefined && {
|
|
20200
20792
|
addresses: resolvedAddresses
|
|
@@ -20825,7 +21417,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20825
21417
|
* is formatted as a human-readable decimal string; when decimals are
|
|
20826
21418
|
* missing the field is omitted entirely (never raw base units).
|
|
20827
21419
|
*
|
|
20828
|
-
* @param params - `txHash`, `chainIn`, optional `chainOut`, and `
|
|
21420
|
+
* @param params - `txHash`, `chainIn`, optional `chainOut`, and `apiKey`.
|
|
20829
21421
|
* @returns A snapshot of the swap's status at the time of the call.
|
|
20830
21422
|
* @throws \{KitError\} If `chainIn` or `chainOut` is malformed.
|
|
20831
21423
|
*
|
|
@@ -20838,7 +21430,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20838
21430
|
* txHash: result.txHash,
|
|
20839
21431
|
* chainIn: result.chainIn,
|
|
20840
21432
|
* chainOut: result.chainOut,
|
|
20841
|
-
*
|
|
21433
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20842
21434
|
* })
|
|
20843
21435
|
* console.log(status.progress.status, status.progress.substatus)
|
|
20844
21436
|
* ```
|
|
@@ -20850,7 +21442,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20850
21442
|
* txHash: result.txHash,
|
|
20851
21443
|
* chainIn: result.chainIn,
|
|
20852
21444
|
* chainOut: result.chainOut,
|
|
20853
|
-
*
|
|
21445
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20854
21446
|
* })
|
|
20855
21447
|
* while (status.progress.status === 'PENDING') {
|
|
20856
21448
|
* await new Promise((r) => setTimeout(r, 3_000))
|
|
@@ -20858,7 +21450,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20858
21450
|
* txHash: result.txHash,
|
|
20859
21451
|
* chainIn: result.chainIn,
|
|
20860
21452
|
* chainOut: result.chainOut,
|
|
20861
|
-
*
|
|
21453
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20862
21454
|
* })
|
|
20863
21455
|
* }
|
|
20864
21456
|
*
|
|
@@ -20889,7 +21481,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20889
21481
|
* 5xx, etc.) surface unchanged so the caller can decide whether to
|
|
20890
21482
|
* retry the whole wait. The wait itself only emits a timeout error.
|
|
20891
21483
|
*
|
|
20892
|
-
* @param params - Wait configuration including identifiers,
|
|
21484
|
+
* @param params - Wait configuration including identifiers, API key,
|
|
20893
21485
|
* optional `timeoutMs`, and an optional `onProgress`
|
|
20894
21486
|
* callback fired on every successful poll.
|
|
20895
21487
|
* @returns The first terminal {@link SwapStatusResult} observed.
|
|
@@ -20908,7 +21500,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20908
21500
|
*
|
|
20909
21501
|
* const final = await kit.waitForSwap({
|
|
20910
21502
|
* result,
|
|
20911
|
-
*
|
|
21503
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20912
21504
|
* onProgress: (snap) => console.log(snap.progress.substatus ?? snap.progress.status),
|
|
20913
21505
|
* })
|
|
20914
21506
|
*
|
|
@@ -20926,7 +21518,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20926
21518
|
* txHash: persisted.txHash,
|
|
20927
21519
|
* chainIn: persisted.chainIn,
|
|
20928
21520
|
* chainOut: persisted.chainOut,
|
|
20929
|
-
*
|
|
21521
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20930
21522
|
* })
|
|
20931
21523
|
* ```
|
|
20932
21524
|
*/ async waitForSwap(params) {
|
|
@@ -20960,7 +21552,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20960
21552
|
* not cache a rate for the native asset on that chain, the response simply
|
|
20961
21553
|
* omits the address.
|
|
20962
21554
|
*
|
|
20963
|
-
* @param params - `chain`, optional `tokens`, and `
|
|
21555
|
+
* @param params - `chain`, optional `tokens`, and `apiKey`.
|
|
20964
21556
|
* @returns A nested map of `[chain][address] → { priceUSD, fetchedAt }`.
|
|
20965
21557
|
* @throws \{KitError\} If `chain` is malformed, `tokens` exceeds 100
|
|
20966
21558
|
* entries, or any entry is neither a registered symbol nor a
|
|
@@ -20972,7 +21564,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20972
21564
|
* const { rates } = await kit.getTokenRates({
|
|
20973
21565
|
* chain: 'Ethereum',
|
|
20974
21566
|
* tokens: ['USDC', 'EURC', 'NATIVE'],
|
|
20975
|
-
*
|
|
21567
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20976
21568
|
* })
|
|
20977
21569
|
*
|
|
20978
21570
|
* const usdc = rates['Ethereum']?.['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48']
|
|
@@ -20986,7 +21578,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20986
21578
|
* chain: 'Ethereum',
|
|
20987
21579
|
* // 'USDC' (registry symbol) + raw USDT address
|
|
20988
21580
|
* tokens: ['USDC', '0xdAC17F958D2ee523a2206206994597C13D831ec7'],
|
|
20989
|
-
*
|
|
21581
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20990
21582
|
* })
|
|
20991
21583
|
* ```
|
|
20992
21584
|
*
|
|
@@ -20995,7 +21587,7 @@ function resolveTokenEntry(entry, index, chain, chainDef, context) {
|
|
|
20995
21587
|
* ```typescript
|
|
20996
21588
|
* const { rates } = await kit.getTokenRates({
|
|
20997
21589
|
* chain: 'Base',
|
|
20998
|
-
*
|
|
21590
|
+
* apiKey: process.env.CIRCLE_API_KEY,
|
|
20999
21591
|
* })
|
|
21000
21592
|
* ```
|
|
21001
21593
|
*/ async getTokenRates(params) {
|
|
@@ -21250,7 +21842,7 @@ registerKit(`${pkg$1.name}/${pkg$1.version}`);
|
|
|
21250
21842
|
};
|
|
21251
21843
|
|
|
21252
21844
|
var name = "@circle-fin/earn-kit";
|
|
21253
|
-
var version = "1.
|
|
21845
|
+
var version = "1.6.0";
|
|
21254
21846
|
var pkg = {
|
|
21255
21847
|
name: name,
|
|
21256
21848
|
version: version};
|
|
@@ -21322,7 +21914,7 @@ function isNonNegativeBigIntLike(value) {
|
|
|
21322
21914
|
}
|
|
21323
21915
|
}
|
|
21324
21916
|
const hexSignatureSchema = evmSignatureSchema;
|
|
21325
|
-
const hexAddressSchema = evmAddressSchema;
|
|
21917
|
+
const hexAddressSchema = evmAddressSchema$1;
|
|
21326
21918
|
// '0x' prefix + 32 bytes * 2 hex chars.
|
|
21327
21919
|
const BYTES32_HEX_LENGTH = 66;
|
|
21328
21920
|
const bridgeFeeTokenSchema = hexAddressSchema;
|
|
@@ -22227,7 +22819,7 @@ createTokenRegistry();
|
|
|
22227
22819
|
* fast instead of round-tripping to the service.
|
|
22228
22820
|
*
|
|
22229
22821
|
* @internal
|
|
22230
|
-
*/ const recipientEvmAddressSchema = evmAddressSchema.refine((address)=>!ZERO_EVM_ADDRESS_REGEX.test(address), 'address must not be the zero address').refine(isValidEip55Checksum, 'address has an invalid EIP-55 checksum');
|
|
22822
|
+
*/ const recipientEvmAddressSchema = evmAddressSchema$1.refine((address)=>!ZERO_EVM_ADDRESS_REGEX.test(address), 'address must not be the zero address').refine(isValidEip55Checksum, 'address has an invalid EIP-55 checksum');
|
|
22231
22823
|
/**
|
|
22232
22824
|
* Schema for the adapter context within earn operations.
|
|
22233
22825
|
*
|
|
@@ -22259,19 +22851,39 @@ const sourceAdapterContextSchema = zod.z.object({
|
|
|
22259
22851
|
/**
|
|
22260
22852
|
* Schema for the EarnConfig options.
|
|
22261
22853
|
*
|
|
22262
|
-
* Validate the
|
|
22263
|
-
*
|
|
22264
|
-
*
|
|
22265
|
-
*
|
|
22266
|
-
*
|
|
22267
|
-
*
|
|
22854
|
+
* Validate the *resolved* credential using the standard `apiKeySchema` format
|
|
22855
|
+
* (`<ENV>_API_KEY:<keyId>:<keySecret>`, or a legacy
|
|
22856
|
+
* `KIT_KEY:<keyId>:<keySecret>`). `apiKey` takes precedence over the deprecated
|
|
22857
|
+
* `kitKey`, so a malformed `kitKey` that is being ignored must not fail a config
|
|
22858
|
+
* that supplies a valid `apiKey` (and vice versa) — only the credential that
|
|
22859
|
+
* would actually be sent is format-checked. When neither is supplied the SDK
|
|
22860
|
+
* operates in permissionless mode. `baseUrl` overrides the Earn Service endpoint
|
|
22861
|
+
* (e.g. staging); `batchTransactions: false` opts out of atomic batched
|
|
22862
|
+
* execution. All are forwarded to the provider, so this `.strict()` schema must
|
|
22863
|
+
* accept them or a valid config object is rejected.
|
|
22268
22864
|
*
|
|
22269
22865
|
* @internal
|
|
22270
22866
|
*/ const earnConfigSchema = zod.z.object({
|
|
22271
|
-
|
|
22867
|
+
apiKey: zod.z.string().optional(),
|
|
22868
|
+
kitKey: zod.z.string().optional(),
|
|
22272
22869
|
baseUrl: zod.z.string().optional(),
|
|
22273
22870
|
batchTransactions: zod.z.boolean().optional()
|
|
22274
|
-
}).strict()
|
|
22871
|
+
}).strict().superRefine((config, ctx)=>{
|
|
22872
|
+
const credential = resolveApiKey(config);
|
|
22873
|
+
if (credential === undefined) {
|
|
22874
|
+
return;
|
|
22875
|
+
}
|
|
22876
|
+
const result = apiKeySchema.safeParse(credential);
|
|
22877
|
+
if (!result.success) {
|
|
22878
|
+
ctx.addIssue({
|
|
22879
|
+
code: zod.z.ZodIssueCode.custom,
|
|
22880
|
+
path: [
|
|
22881
|
+
credential === config.apiKey ? 'apiKey' : 'kitKey'
|
|
22882
|
+
],
|
|
22883
|
+
message: result.error.issues[0]?.message ?? 'Invalid API key format'
|
|
22884
|
+
});
|
|
22885
|
+
}
|
|
22886
|
+
});
|
|
22275
22887
|
/**
|
|
22276
22888
|
* Canonical decimal form: a leading digit with no leading zeros (a single
|
|
22277
22889
|
* '0' is only allowed immediately before the decimal point). Rejects the
|
|
@@ -22343,7 +22955,7 @@ const sourceAdapterContextSchema = zod.z.object({
|
|
|
22343
22955
|
* currently supports EVM vault addresses on Arc Testnet.
|
|
22344
22956
|
*
|
|
22345
22957
|
* @internal
|
|
22346
|
-
*/ const vaultAddressSchema = evmAddressSchema.refine(isValidEip55Checksum, 'address has an invalid EIP-55 checksum');
|
|
22958
|
+
*/ const vaultAddressSchema = evmAddressSchema$1.refine(isValidEip55Checksum, 'address has an invalid EIP-55 checksum');
|
|
22347
22959
|
/**
|
|
22348
22960
|
* Validation schema for VaultQuery.
|
|
22349
22961
|
*
|
|
@@ -22618,7 +23230,7 @@ const sameChainGetDepositQuoteParamsSchema = zod.z.object({
|
|
|
22618
23230
|
const crossChainGetDepositQuoteParamsSchema = zod.z.object({
|
|
22619
23231
|
from: sourceAdapterContextSchema,
|
|
22620
23232
|
chain: earnBridgeDestinationChainIdentifierSchema,
|
|
22621
|
-
address: evmAddressSchema,
|
|
23233
|
+
address: evmAddressSchema$1,
|
|
22622
23234
|
vaultAddress: vaultAddressSchema,
|
|
22623
23235
|
amount: amountSchema,
|
|
22624
23236
|
transferSpeed: zod.z.enum([
|