Skip to content

Commit 33a1470

Browse files
committed
feat: updated slpx testnet
1 parent 191aba9 commit 33a1470

2 files changed

Lines changed: 43 additions & 16 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "slpx-sdk",
33
"type": "module",
4-
"version": "0.0.9",
4+
"version": "0.0.10",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.js",
77
"types": "./dist/index.d.ts",

src/slpx-testnet.ts

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getTestnetAssetAddress, getChainNameFromChainId } from "./utils";
1818
* @param chain - The name or chain ID of the testnet chain
1919
* @param amount - The amount to send as a string (will be parsed with 18 decimals)
2020
* @param partnerCode - The partner code to use for the mint
21+
* @param eip7702 - Whether to use EIP-7702 standard
2122
* @returns Contract call params for estimateSendAndCallFee function
2223
* @throws Error if underlying asset address is not supported for the given chain
2324
* @throws Error if amount is not a positive number
@@ -27,7 +28,8 @@ export function getTestnetMintParams(
2728
underlyingAssetName: MintingAssetName,
2829
chain: ValidTestnetChainInput,
2930
amount: string,
30-
partnerCode: string = "bifrost"
31+
partnerCode: string = "bifrost",
32+
eip7702: boolean = false
3133
) {
3234
// Check if the underlying asset address is valid
3335
const underlyingAssetAddress = getTestnetAssetAddress(
@@ -57,13 +59,25 @@ export function getTestnetMintParams(
5759
throw new Error("Partner code must be a string");
5860
}
5961

60-
const testnetMintParams = {
61-
address: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
62-
abi: TESTNET_SLPX_V2_ABI,
63-
functionName: "createOrder",
64-
value: underlyingAssetName === "eth" ? parseUnits(amount, 18) : undefined,
65-
args: [underlyingAssetAddress, parseUnits(amount, 18), 0, partnerCode],
66-
};
62+
let testnetMintParams;
63+
64+
if (eip7702) {
65+
testnetMintParams = {
66+
to: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
67+
abi: TESTNET_SLPX_V2_ABI,
68+
functionName: "createOrder",
69+
value: underlyingAssetName === "eth" ? parseUnits(amount, 18) : undefined,
70+
args: [underlyingAssetAddress, parseUnits(amount, 18), 0, partnerCode],
71+
};
72+
} else {
73+
testnetMintParams = {
74+
address: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
75+
abi: TESTNET_SLPX_V2_ABI,
76+
functionName: "createOrder",
77+
value: underlyingAssetName === "eth" ? parseUnits(amount, 18) : undefined,
78+
args: [underlyingAssetAddress, parseUnits(amount, 18), 0, partnerCode],
79+
};
80+
}
6781

6882
// Return the testnet mint params
6983
return testnetMintParams;
@@ -75,6 +89,7 @@ export function getTestnetMintParams(
7589
* @param chain - The name or chain ID of the testnet chain
7690
* @param amount - The amount to send as a string (will be parsed with 18 decimals)
7791
* @param partnerCode - The partner code to use for the mint
92+
* @param eip7702 - Whether to use EIP-7702 standard
7893
* @returns Contract call params for createOrder function
7994
* @throws Error if underlying asset address is not supported for the given chain
8095
* @throws Error if amount is not a positive number
@@ -84,7 +99,8 @@ export function getTestnetRedeemParams(
8499
underlyingAssetName: MintingAssetName,
85100
chain: ValidTestnetChainInput,
86101
amount: string,
87-
partnerCode: string = "bifrost"
102+
partnerCode: string = "bifrost",
103+
eip7702: boolean = false
88104
) {
89105
// Check if the underlying asset address is valid
90106
const underlyingAssetAddress = getTestnetAssetAddress(
@@ -114,12 +130,23 @@ export function getTestnetRedeemParams(
114130
throw new Error("Partner code must be a string");
115131
}
116132

117-
const testnetRedeemParams = {
118-
address: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
119-
abi: TESTNET_SLPX_V2_ABI,
120-
functionName: "createOrder",
121-
args: [underlyingAssetAddress, parseUnits(amount, 18), 1, partnerCode],
122-
};
133+
let testnetRedeemParams;
134+
135+
if (eip7702) {
136+
testnetRedeemParams = {
137+
to: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
138+
abi: TESTNET_SLPX_V2_ABI,
139+
functionName: "createOrder",
140+
args: [underlyingAssetAddress, parseUnits(amount, 18), 1, partnerCode],
141+
};
142+
} else {
143+
testnetRedeemParams = {
144+
address: CONTRACT_ADDRESS_INFO[chainName].slpx!.address,
145+
abi: TESTNET_SLPX_V2_ABI,
146+
functionName: "createOrder",
147+
args: [underlyingAssetAddress, parseUnits(amount, 18), 1, partnerCode],
148+
};
149+
}
123150

124151
// Return the testnet mint params
125152
return testnetRedeemParams;

0 commit comments

Comments
 (0)