@wirexapp/wpay-baas-sdk 0.1.10 → 0.1.11
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/README.md +6 -2
- package/dist/{chunk-GOPZA7GB.js → chunk-YGNDXSTF.js} +82 -27
- package/dist/chunk-YGNDXSTF.js.map +1 -0
- package/dist/{crypto.module-b1_0pvdU.d.ts → crypto.module-DMKRqQiN.d.ts} +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/modules/crypto/index.d.ts +2 -2
- package/dist/modules/crypto/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GOPZA7GB.js.map +0 -1
package/README.md
CHANGED
|
@@ -332,14 +332,18 @@ interface YieldData {
|
|
|
332
332
|
|--------|-------------|
|
|
333
333
|
| `initializeSmartDepositAddresses(forceRefresh?)` | Create/get all deposit addresses |
|
|
334
334
|
| `getAddresses()` | Get cached addresses |
|
|
335
|
+
| `getDestinationChain()` | Rhino.fi chain code funds are bridged to |
|
|
335
336
|
| `clearAddresses()` | Clear address cache |
|
|
336
337
|
|
|
337
|
-
**
|
|
338
|
+
**Destination chain** follows the SDK `chainId`: `8453` / `84532` → `BASE`, `5042` / `5042002` → `ARC`. Rhino.fi has no testnet chains, so testnet ids resolve to the mainnet code.
|
|
339
|
+
|
|
340
|
+
Deposit chains with no bridgeable route to the destination (Rhino.fi `DepositAddressNoBridgableTokens`, e.g. USDT-only Kaia and TRON towards Arc) are skipped with a warning; the remaining chains in the group are still created.
|
|
341
|
+
|
|
342
|
+
**Supported deposit networks:**
|
|
338
343
|
- EVM: Base, Arbitrum, BNB Chain, Ethereum, Kaia, Polygon, Optimism
|
|
339
344
|
- TRON
|
|
340
345
|
- Solana
|
|
341
346
|
- Stellar
|
|
342
|
-
- Solana
|
|
343
347
|
|
|
344
348
|
---
|
|
345
349
|
|
|
@@ -4803,6 +4803,8 @@ var ContractRegistryService = class {
|
|
|
4803
4803
|
}
|
|
4804
4804
|
}
|
|
4805
4805
|
};
|
|
4806
|
+
var STELLAR_CHAIN = "STELLAR";
|
|
4807
|
+
var ARC_CHAIN = "ARC";
|
|
4806
4808
|
var supportedEVMChains = [
|
|
4807
4809
|
SupportedChains.BASE,
|
|
4808
4810
|
SupportedChains.ARBITRUM_ONE,
|
|
@@ -4812,14 +4814,41 @@ var supportedEVMChains = [
|
|
|
4812
4814
|
SupportedChains.POLYGON,
|
|
4813
4815
|
SupportedChains.OPTIMISM
|
|
4814
4816
|
];
|
|
4815
|
-
var
|
|
4817
|
+
var RHINO_DESTINATION_CHAIN_BY_CHAIN_ID = {
|
|
4818
|
+
8453: SupportedChains.BASE,
|
|
4819
|
+
84532: SupportedChains.BASE,
|
|
4820
|
+
5042: ARC_CHAIN,
|
|
4821
|
+
5042002: ARC_CHAIN
|
|
4822
|
+
};
|
|
4823
|
+
function resolveRhinoDestinationChain(chainId) {
|
|
4824
|
+
const destinationChain = RHINO_DESTINATION_CHAIN_BY_CHAIN_ID[chainId];
|
|
4825
|
+
if (!destinationChain) {
|
|
4826
|
+
const supported = Object.keys(RHINO_DESTINATION_CHAIN_BY_CHAIN_ID).join(", ");
|
|
4827
|
+
throw new ConfigurationError(
|
|
4828
|
+
`No Rhino.fi destination chain for chainId ${chainId}. Supported: ${supported}`
|
|
4829
|
+
);
|
|
4830
|
+
}
|
|
4831
|
+
return destinationChain;
|
|
4832
|
+
}
|
|
4816
4833
|
var SYSTEM_SUPPORTED_TOKENS = ["USDT", "USDC", "EURC"];
|
|
4834
|
+
var NO_BRIDGEABLE_TOKENS_TAG = "DepositAddressNoBridgableTokens";
|
|
4835
|
+
function getUnbridgeableChain(error) {
|
|
4836
|
+
if (!error || typeof error !== "object") {
|
|
4837
|
+
return void 0;
|
|
4838
|
+
}
|
|
4839
|
+
const { _tag, from } = error;
|
|
4840
|
+
return _tag === NO_BRIDGEABLE_TOKENS_TAG && typeof from === "string" ? from : void 0;
|
|
4841
|
+
}
|
|
4817
4842
|
var SmartDepositAddressesService = class {
|
|
4818
4843
|
constructor(config) {
|
|
4819
4844
|
this.rhinoSdkInstance = null;
|
|
4820
4845
|
this.addresses = [];
|
|
4821
4846
|
this.walletService = config.walletService;
|
|
4822
4847
|
this.rhinoApiKey = config.rhinoApiKey;
|
|
4848
|
+
this.destinationChain = resolveRhinoDestinationChain(config.chainId);
|
|
4849
|
+
}
|
|
4850
|
+
getDestinationChain() {
|
|
4851
|
+
return this.destinationChain;
|
|
4823
4852
|
}
|
|
4824
4853
|
async initializeSmartDepositAddresses(forceRefresh = false) {
|
|
4825
4854
|
if (this.addresses.length > 0 && !forceRefresh) {
|
|
@@ -4838,7 +4867,7 @@ var SmartDepositAddressesService = class {
|
|
|
4838
4867
|
if (!hasTronAddresses) failedGroups.push("TRON");
|
|
4839
4868
|
if (!hasSolanaAddresses) failedGroups.push("Solana");
|
|
4840
4869
|
if (!hasStellarAddresses) failedGroups.push("Stellar");
|
|
4841
|
-
console.warn(`
|
|
4870
|
+
console.warn(`No deposit addresses for chain groups: ${failedGroups.join(", ")}`);
|
|
4842
4871
|
}
|
|
4843
4872
|
this.setAddresses(allAddresses);
|
|
4844
4873
|
return allAddresses;
|
|
@@ -4860,31 +4889,47 @@ var SmartDepositAddressesService = class {
|
|
|
4860
4889
|
const smartWalletClient = await this.walletService.getSmartWalletClient();
|
|
4861
4890
|
const smartWalletAddress = smartWalletClient.account.address;
|
|
4862
4891
|
const sdk = this.getRhinoSdk();
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
throw new Error(JSON.stringify(response.error));
|
|
4876
|
-
}
|
|
4877
|
-
const activationPromises = response.data.filter((depositData) => !depositData.isActive).map(async (depositData) => {
|
|
4878
|
-
const activationResponse = await sdk.api.depositAddresses.activate({
|
|
4879
|
-
depositAddress: depositData.depositAddress,
|
|
4880
|
-
depositChain: depositData.depositChain
|
|
4892
|
+
let depositChains = [...supportedChains];
|
|
4893
|
+
while (depositChains.length > 0) {
|
|
4894
|
+
const response = await sdk.api.depositAddresses.create({
|
|
4895
|
+
depositChains,
|
|
4896
|
+
destinationChain: this.destinationChain,
|
|
4897
|
+
destinationAddress: smartWalletAddress,
|
|
4898
|
+
bridgeIfNotSwappable: true,
|
|
4899
|
+
tokenOut: "USDC",
|
|
4900
|
+
postBridgeData: {
|
|
4901
|
+
_tag: "wirexwrap"
|
|
4902
|
+
},
|
|
4903
|
+
reusePolicy: "reuse-existing"
|
|
4881
4904
|
});
|
|
4882
|
-
if (
|
|
4883
|
-
|
|
4905
|
+
if (response.response.status === 200 && response.data) {
|
|
4906
|
+
return this.activateDepositAddresses(sdk, response.data);
|
|
4907
|
+
}
|
|
4908
|
+
const unbridgeableChain = getUnbridgeableChain(response.error);
|
|
4909
|
+
if (!unbridgeableChain || !depositChains.includes(unbridgeableChain)) {
|
|
4910
|
+
throw new Error(JSON.stringify(response.error));
|
|
4911
|
+
}
|
|
4912
|
+
console.warn(
|
|
4913
|
+
`No bridgeable tokens from ${unbridgeableChain} to ${this.destinationChain}, skipping chain`
|
|
4914
|
+
);
|
|
4915
|
+
depositChains = depositChains.filter((chain) => chain !== unbridgeableChain);
|
|
4916
|
+
}
|
|
4917
|
+
return [];
|
|
4918
|
+
}
|
|
4919
|
+
async activateDepositAddresses(sdk, depositAddresses) {
|
|
4920
|
+
const inactiveAddresses = depositAddresses.filter((depositData) => !depositData.isActive);
|
|
4921
|
+
const activationResults = await Promise.allSettled(
|
|
4922
|
+
inactiveAddresses.map((depositData) => this.activateDepositAddress(sdk, depositData))
|
|
4923
|
+
);
|
|
4924
|
+
const failedChains = /* @__PURE__ */ new Set();
|
|
4925
|
+
activationResults.forEach((result, index) => {
|
|
4926
|
+
if (result.status === "rejected") {
|
|
4927
|
+
const chain = inactiveAddresses[index].depositChain;
|
|
4928
|
+
failedChains.add(chain);
|
|
4929
|
+
console.error(`Failed to activate ${chain} deposit address:`, result.reason);
|
|
4884
4930
|
}
|
|
4885
4931
|
});
|
|
4886
|
-
|
|
4887
|
-
return response.data.map((item) => {
|
|
4932
|
+
return depositAddresses.filter((item) => !failedChains.has(item.depositChain)).map((item) => {
|
|
4888
4933
|
const supportedTokens = (item.supportedTokens || []).map((token) => token.symbol).filter((symbol) => SYSTEM_SUPPORTED_TOKENS.includes(symbol));
|
|
4889
4934
|
return {
|
|
4890
4935
|
depositChain: item.depositChain,
|
|
@@ -4896,6 +4941,15 @@ var SmartDepositAddressesService = class {
|
|
|
4896
4941
|
};
|
|
4897
4942
|
});
|
|
4898
4943
|
}
|
|
4944
|
+
async activateDepositAddress(sdk, depositData) {
|
|
4945
|
+
const activationResponse = await sdk.api.depositAddresses.activate({
|
|
4946
|
+
depositAddress: depositData.depositAddress,
|
|
4947
|
+
depositChain: depositData.depositChain
|
|
4948
|
+
});
|
|
4949
|
+
if (activationResponse.response.status !== 200) {
|
|
4950
|
+
throw new Error(JSON.stringify(activationResponse.error));
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4899
4953
|
async createSmartDepositAddresses() {
|
|
4900
4954
|
const results = await Promise.allSettled([
|
|
4901
4955
|
this.createSmartDepositAddressForChains(supportedEVMChains),
|
|
@@ -5132,7 +5186,8 @@ var CryptoModule = class {
|
|
|
5132
5186
|
if (config.rhinoApiKey) {
|
|
5133
5187
|
this._smartDepositService = new SmartDepositAddressesService({
|
|
5134
5188
|
walletService: this._walletService,
|
|
5135
|
-
rhinoApiKey: config.rhinoApiKey
|
|
5189
|
+
rhinoApiKey: config.rhinoApiKey,
|
|
5190
|
+
chainId: config.chainId
|
|
5136
5191
|
});
|
|
5137
5192
|
}
|
|
5138
5193
|
}
|
|
@@ -5143,5 +5198,5 @@ var CryptoModule = class {
|
|
|
5143
5198
|
};
|
|
5144
5199
|
|
|
5145
5200
|
export { BaseAccountAbstractionService, BaseAccountContractService, BaseCryptoService, BaseOnboardingService, BaseWalletService, BaseYieldService, ContractRegistryService, CryptoModule, chainRegistry };
|
|
5146
|
-
//# sourceMappingURL=chunk-
|
|
5147
|
-
//# sourceMappingURL=chunk-
|
|
5201
|
+
//# sourceMappingURL=chunk-YGNDXSTF.js.map
|
|
5202
|
+
//# sourceMappingURL=chunk-YGNDXSTF.js.map
|