@talismn/sapi 0.0.12 → 0.1.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/dist/declarations/src/helpers/getSapiConnector.d.ts +1 -1
- package/dist/declarations/src/helpers/submit.d.ts +6 -0
- package/dist/declarations/src/sapi.d.ts +2 -1
- package/dist/declarations/src/types.d.ts +3 -0
- package/dist/talismn-sapi.cjs.dev.js +17 -2
- package/dist/talismn-sapi.cjs.prod.js +17 -2
- package/dist/talismn-sapi.esm.js +17 -2
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SapiConnectorProps } from "../types";
|
|
2
2
|
export type SapiConnector = Required<SapiConnectorProps>;
|
|
3
|
-
export declare const getSapiConnector: ({ chainId, send, submit }: SapiConnectorProps) => SapiConnector;
|
|
3
|
+
export declare const getSapiConnector: ({ chainId, send, submit, submitWithBittensorMevShield, }: SapiConnectorProps) => SapiConnector;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SignerPayloadJSON } from "@polkadot/types/types";
|
|
2
|
+
import { Chain } from "./types";
|
|
3
|
+
export type ScaleApiSubmitMode = "default" | "bittensor-mev-shield";
|
|
4
|
+
export declare const submit: (chain: Chain, payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown, mode?: ScaleApiSubmitMode) => Promise<{
|
|
5
|
+
hash: `0x${string}`;
|
|
6
|
+
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
|
2
2
|
import { SignerPayloadJSON } from "@polkadot/types/types";
|
|
3
|
+
import { ScaleApiSubmitMode } from "./helpers/submit";
|
|
3
4
|
import { Chain } from "./helpers/types";
|
|
4
5
|
import { DecodedCall, PayloadSignerConfig, SapiConnectorProps } from "./types";
|
|
5
6
|
export type ScaleApi = NonNullable<ReturnType<typeof getScaleApi>>;
|
|
@@ -38,7 +39,7 @@ export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `
|
|
|
38
39
|
getFeeEstimate: (payload: SignerPayloadJSON) => Promise<bigint>;
|
|
39
40
|
getRuntimeCallValue: <T>(apiName: string, method: string, args: unknown[]) => Promise<T>;
|
|
40
41
|
getTypeRegistry: (payload: SignerPayloadJSON) => import("@polkadot/types").TypeRegistry;
|
|
41
|
-
submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown) => Promise<{
|
|
42
|
+
submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown, mode?: ScaleApiSubmitMode) => Promise<{
|
|
42
43
|
hash: `0x${string}`;
|
|
43
44
|
}>;
|
|
44
45
|
getCallDocs: (pallet: string, method: string) => string | null;
|
|
@@ -15,4 +15,7 @@ export type SapiConnectorProps = {
|
|
|
15
15
|
submit?: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: any) => Promise<{
|
|
16
16
|
hash: `0x${string}`;
|
|
17
17
|
}>;
|
|
18
|
+
submitWithBittensorMevShield?: (payload: SignerPayloadJSON, txInfo?: any) => Promise<{
|
|
19
|
+
hash: `0x${string}`;
|
|
20
|
+
}>;
|
|
18
21
|
};
|
|
@@ -315,13 +315,18 @@ const getFeeEstimate = async (chain, payload, chainInfo) => {
|
|
|
315
315
|
const getSapiConnector = ({
|
|
316
316
|
chainId,
|
|
317
317
|
send,
|
|
318
|
-
submit
|
|
318
|
+
submit,
|
|
319
|
+
submitWithBittensorMevShield
|
|
319
320
|
}) => ({
|
|
320
321
|
chainId,
|
|
321
322
|
send,
|
|
322
323
|
submit: (...args) => {
|
|
323
324
|
if (submit) return submit(...args);
|
|
324
325
|
throw new Error("submit handler not provided");
|
|
326
|
+
},
|
|
327
|
+
submitWithBittensorMevShield: (...args) => {
|
|
328
|
+
if (submitWithBittensorMevShield) return submitWithBittensorMevShield(...args);
|
|
329
|
+
throw new Error("submitWithBittensorMevShield handler not provided");
|
|
325
330
|
}
|
|
326
331
|
});
|
|
327
332
|
|
|
@@ -482,6 +487,16 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
|
|
|
482
487
|
};
|
|
483
488
|
};
|
|
484
489
|
|
|
490
|
+
const submit = async (chain, payload, signature, txInfo, mode) => {
|
|
491
|
+
switch (mode) {
|
|
492
|
+
case "bittensor-mev-shield":
|
|
493
|
+
if (signature) throw new Error("Signature should not be provided when using bittensor-mev-shield mode");
|
|
494
|
+
return chain.connector.submitWithBittensorMevShield(payload, txInfo);
|
|
495
|
+
default:
|
|
496
|
+
return chain.connector.submit(payload, signature, txInfo);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
485
500
|
const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
|
|
486
501
|
const {
|
|
487
502
|
unifiedMetadata: metadata,
|
|
@@ -523,7 +538,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
523
538
|
getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
|
|
524
539
|
getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
|
|
525
540
|
getTypeRegistry: payload => getTypeRegistry(chain, payload),
|
|
526
|
-
submit: (payload, signature, txInfo) =>
|
|
541
|
+
submit: (payload, signature, txInfo, mode) => submit(chain, payload, signature, txInfo, mode),
|
|
527
542
|
getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
|
|
528
543
|
getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
|
|
529
544
|
isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
|
|
@@ -315,13 +315,18 @@ const getFeeEstimate = async (chain, payload, chainInfo) => {
|
|
|
315
315
|
const getSapiConnector = ({
|
|
316
316
|
chainId,
|
|
317
317
|
send,
|
|
318
|
-
submit
|
|
318
|
+
submit,
|
|
319
|
+
submitWithBittensorMevShield
|
|
319
320
|
}) => ({
|
|
320
321
|
chainId,
|
|
321
322
|
send,
|
|
322
323
|
submit: (...args) => {
|
|
323
324
|
if (submit) return submit(...args);
|
|
324
325
|
throw new Error("submit handler not provided");
|
|
326
|
+
},
|
|
327
|
+
submitWithBittensorMevShield: (...args) => {
|
|
328
|
+
if (submitWithBittensorMevShield) return submitWithBittensorMevShield(...args);
|
|
329
|
+
throw new Error("submitWithBittensorMevShield handler not provided");
|
|
325
330
|
}
|
|
326
331
|
});
|
|
327
332
|
|
|
@@ -482,6 +487,16 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
|
|
|
482
487
|
};
|
|
483
488
|
};
|
|
484
489
|
|
|
490
|
+
const submit = async (chain, payload, signature, txInfo, mode) => {
|
|
491
|
+
switch (mode) {
|
|
492
|
+
case "bittensor-mev-shield":
|
|
493
|
+
if (signature) throw new Error("Signature should not be provided when using bittensor-mev-shield mode");
|
|
494
|
+
return chain.connector.submitWithBittensorMevShield(payload, txInfo);
|
|
495
|
+
default:
|
|
496
|
+
return chain.connector.submit(payload, signature, txInfo);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
485
500
|
const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
|
|
486
501
|
const {
|
|
487
502
|
unifiedMetadata: metadata,
|
|
@@ -523,7 +538,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
523
538
|
getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
|
|
524
539
|
getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
|
|
525
540
|
getTypeRegistry: payload => getTypeRegistry(chain, payload),
|
|
526
|
-
submit: (payload, signature, txInfo) =>
|
|
541
|
+
submit: (payload, signature, txInfo, mode) => submit(chain, payload, signature, txInfo, mode),
|
|
527
542
|
getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
|
|
528
543
|
getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
|
|
529
544
|
isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
|
package/dist/talismn-sapi.esm.js
CHANGED
|
@@ -309,13 +309,18 @@ const getFeeEstimate = async (chain, payload, chainInfo) => {
|
|
|
309
309
|
const getSapiConnector = ({
|
|
310
310
|
chainId,
|
|
311
311
|
send,
|
|
312
|
-
submit
|
|
312
|
+
submit,
|
|
313
|
+
submitWithBittensorMevShield
|
|
313
314
|
}) => ({
|
|
314
315
|
chainId,
|
|
315
316
|
send,
|
|
316
317
|
submit: (...args) => {
|
|
317
318
|
if (submit) return submit(...args);
|
|
318
319
|
throw new Error("submit handler not provided");
|
|
320
|
+
},
|
|
321
|
+
submitWithBittensorMevShield: (...args) => {
|
|
322
|
+
if (submitWithBittensorMevShield) return submitWithBittensorMevShield(...args);
|
|
323
|
+
throw new Error("submitWithBittensorMevShield handler not provided");
|
|
319
324
|
}
|
|
320
325
|
});
|
|
321
326
|
|
|
@@ -476,6 +481,16 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
|
|
|
476
481
|
};
|
|
477
482
|
};
|
|
478
483
|
|
|
484
|
+
const submit = async (chain, payload, signature, txInfo, mode) => {
|
|
485
|
+
switch (mode) {
|
|
486
|
+
case "bittensor-mev-shield":
|
|
487
|
+
if (signature) throw new Error("Signature should not be provided when using bittensor-mev-shield mode");
|
|
488
|
+
return chain.connector.submitWithBittensorMevShield(payload, txInfo);
|
|
489
|
+
default:
|
|
490
|
+
return chain.connector.submit(payload, signature, txInfo);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
479
494
|
const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
|
|
480
495
|
const {
|
|
481
496
|
unifiedMetadata: metadata,
|
|
@@ -517,7 +532,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
517
532
|
getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
|
|
518
533
|
getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
|
|
519
534
|
getTypeRegistry: payload => getTypeRegistry(chain, payload),
|
|
520
|
-
submit: (payload, signature, txInfo) =>
|
|
535
|
+
submit: (payload, signature, txInfo, mode) => submit(chain, payload, signature, txInfo, mode),
|
|
521
536
|
getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
|
|
522
537
|
getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
|
|
523
538
|
isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/sapi",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Talisman",
|
|
5
5
|
"homepage": "https://talisman.xyz",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"anylogger": "^1.0.11",
|
|
32
32
|
"polkadot-api": "1.13.1",
|
|
33
33
|
"scale-ts": "^1.6.1",
|
|
34
|
-
"@talismn/scale": "0.
|
|
34
|
+
"@talismn/scale": "0.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "^29.5.14",
|