arc-sdk-test 0.0.1 → 0.0.3
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/dist/ArcaneSDK-dPZCBtDG.d.cts +360 -0
- package/dist/ArcaneSDK-dPZCBtDG.d.ts +360 -0
- package/dist/index.cjs +33 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -337
- package/dist/index.d.ts +5 -337
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +12869 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +33 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.js +12843 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +30 -5
package/dist/index.js
CHANGED
|
@@ -2927,11 +2927,28 @@ async function fetchRelayersForNetwork(network, indexerUrl = getIndexerUrlForNet
|
|
|
2927
2927
|
).map((result) => result.value);
|
|
2928
2928
|
}
|
|
2929
2929
|
var runtimeContextStack = [];
|
|
2930
|
+
function resolveInitConnection(options) {
|
|
2931
|
+
if (options.connection) {
|
|
2932
|
+
return {
|
|
2933
|
+
connection: options.connection,
|
|
2934
|
+
rpcEndpoint: options.connection.rpcEndpoint
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
if (options.rpcEndpoint) {
|
|
2938
|
+
return {
|
|
2939
|
+
connection: new Connection(options.rpcEndpoint),
|
|
2940
|
+
rpcEndpoint: options.rpcEndpoint
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
throw new Error(
|
|
2944
|
+
"arc-sdk-test: provide either rpcEndpoint or connection in ArcaneSDK.create()"
|
|
2945
|
+
);
|
|
2946
|
+
}
|
|
2930
2947
|
async function createRuntimeConfig(options) {
|
|
2931
|
-
const
|
|
2948
|
+
const { connection, rpcEndpoint } = resolveInitConnection(options);
|
|
2949
|
+
const network = options.network ?? resolveNetworkFromRpcEndpoint(rpcEndpoint);
|
|
2932
2950
|
const indexerUrl = getIndexerUrlForNetwork(network);
|
|
2933
2951
|
const relayers = await fetchRelayersForNetwork(network, indexerUrl);
|
|
2934
|
-
const connection = new Connection(options.rpcEndpoint);
|
|
2935
2952
|
const provider = new AnchorProvider(connection, options.wallet, {
|
|
2936
2953
|
commitment: "confirmed"
|
|
2937
2954
|
});
|
|
@@ -2939,7 +2956,7 @@ async function createRuntimeConfig(options) {
|
|
|
2939
2956
|
const program = new Program(getIdlForNetwork(network), provider);
|
|
2940
2957
|
return {
|
|
2941
2958
|
rangeApiKey: options.rangeApiKey,
|
|
2942
|
-
rpcEndpoint
|
|
2959
|
+
rpcEndpoint,
|
|
2943
2960
|
network,
|
|
2944
2961
|
programId: getProgramIdForNetwork(network),
|
|
2945
2962
|
relayers,
|
|
@@ -12304,6 +12321,9 @@ function normalizeRecipient(recipient) {
|
|
|
12304
12321
|
function serializeAmountLamports(amountLamports) {
|
|
12305
12322
|
return typeof amountLamports === "bigint" ? amountLamports.toString() : amountLamports;
|
|
12306
12323
|
}
|
|
12324
|
+
async function fetchPlatformFeePercent() {
|
|
12325
|
+
return parseFloat(await fetchPlatformFee2()) / 100;
|
|
12326
|
+
}
|
|
12307
12327
|
async function getQuote(params) {
|
|
12308
12328
|
const network = params.network ?? getConfig().network;
|
|
12309
12329
|
const res = await fetch(`${getIndexerUrl()}/quote`, {
|
|
@@ -12328,7 +12348,16 @@ async function getQuote(params) {
|
|
|
12328
12348
|
if (!data.success) {
|
|
12329
12349
|
throw new Error("Quote request was not successful");
|
|
12330
12350
|
}
|
|
12331
|
-
|
|
12351
|
+
const platformFeePercent = await fetchPlatformFeePercent();
|
|
12352
|
+
const platformFee = data.quote.amount * platformFeePercent;
|
|
12353
|
+
return {
|
|
12354
|
+
...data,
|
|
12355
|
+
quote: {
|
|
12356
|
+
...data.quote,
|
|
12357
|
+
recipientAmount: data.quote.recipientAmount - platformFee,
|
|
12358
|
+
platformFee
|
|
12359
|
+
}
|
|
12360
|
+
};
|
|
12332
12361
|
}
|
|
12333
12362
|
|
|
12334
12363
|
// src/transfer/splitAmount.ts
|