@the-situation/sdk 0.2.0-alpha.1 → 0.2.0-alpha.2
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/utils/call-format.d.ts +58 -0
- package/dist/utils/call-format.d.ts.map +1 -0
- package/dist/utils/call-format.js +54 -0
- package/dist/utils/call-format.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call format conversion utilities for wallet connector compatibility.
|
|
3
|
+
*
|
|
4
|
+
* starknet.js uses camelCase (`contractAddress`, `entrypoint`) but the
|
|
5
|
+
* Starknet JSON-RPC spec uses snake_case (`contract_address`, `entry_point`).
|
|
6
|
+
* Some wallet connectors (e.g., starknetkit) validate against the RPC format.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { Call } from 'starknet';
|
|
11
|
+
/**
|
|
12
|
+
* Call object in snake_case format (JSON-RPC spec format).
|
|
13
|
+
*
|
|
14
|
+
* Used by some wallet connectors like starknetkit that validate
|
|
15
|
+
* against the raw RPC format rather than starknet.js types.
|
|
16
|
+
*/
|
|
17
|
+
export interface CallRpc {
|
|
18
|
+
contract_address: string;
|
|
19
|
+
entry_point: string;
|
|
20
|
+
calldata: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Converts a starknet.js Call to snake_case RPC format.
|
|
24
|
+
*
|
|
25
|
+
* Use this when your wallet connector (e.g., starknetkit) expects
|
|
26
|
+
* snake_case field names instead of starknet.js camelCase format.
|
|
27
|
+
*
|
|
28
|
+
* @param call - starknet.js Call object (camelCase)
|
|
29
|
+
* @returns Call in RPC format (snake_case)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { toRpcCall } from '@the-situation/sdk';
|
|
34
|
+
*
|
|
35
|
+
* const trade = await market.prepareTrade({ targetMean: 105 });
|
|
36
|
+
* const rpcCalls = trade.calls.map(toRpcCall);
|
|
37
|
+
* await account.execute(rpcCalls);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function toRpcCall(call: Call): CallRpc;
|
|
41
|
+
/**
|
|
42
|
+
* Converts an array of starknet.js Calls to snake_case RPC format.
|
|
43
|
+
*
|
|
44
|
+
* Convenience wrapper for `calls.map(toRpcCall)`.
|
|
45
|
+
*
|
|
46
|
+
* @param calls - Array of starknet.js Call objects (camelCase)
|
|
47
|
+
* @returns Array of Calls in RPC format (snake_case)
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { toRpcCalls } from '@the-situation/sdk';
|
|
52
|
+
*
|
|
53
|
+
* const trade = await market.prepareTrade({ targetMean: 105 });
|
|
54
|
+
* await account.execute(toRpcCalls(trade.calls));
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function toRpcCalls(calls: Call[]): CallRpc[];
|
|
58
|
+
//# sourceMappingURL=call-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-format.d.ts","sourceRoot":"","sources":["../../src/utils/call-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAM7C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAEnD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call format conversion utilities for wallet connector compatibility.
|
|
3
|
+
*
|
|
4
|
+
* starknet.js uses camelCase (`contractAddress`, `entrypoint`) but the
|
|
5
|
+
* Starknet JSON-RPC spec uses snake_case (`contract_address`, `entry_point`).
|
|
6
|
+
* Some wallet connectors (e.g., starknetkit) validate against the RPC format.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Converts a starknet.js Call to snake_case RPC format.
|
|
12
|
+
*
|
|
13
|
+
* Use this when your wallet connector (e.g., starknetkit) expects
|
|
14
|
+
* snake_case field names instead of starknet.js camelCase format.
|
|
15
|
+
*
|
|
16
|
+
* @param call - starknet.js Call object (camelCase)
|
|
17
|
+
* @returns Call in RPC format (snake_case)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { toRpcCall } from '@the-situation/sdk';
|
|
22
|
+
*
|
|
23
|
+
* const trade = await market.prepareTrade({ targetMean: 105 });
|
|
24
|
+
* const rpcCalls = trade.calls.map(toRpcCall);
|
|
25
|
+
* await account.execute(rpcCalls);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function toRpcCall(call) {
|
|
29
|
+
return {
|
|
30
|
+
contract_address: call.contractAddress,
|
|
31
|
+
entry_point: call.entrypoint,
|
|
32
|
+
calldata: call.calldata ?? [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Converts an array of starknet.js Calls to snake_case RPC format.
|
|
37
|
+
*
|
|
38
|
+
* Convenience wrapper for `calls.map(toRpcCall)`.
|
|
39
|
+
*
|
|
40
|
+
* @param calls - Array of starknet.js Call objects (camelCase)
|
|
41
|
+
* @returns Array of Calls in RPC format (snake_case)
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { toRpcCalls } from '@the-situation/sdk';
|
|
46
|
+
*
|
|
47
|
+
* const trade = await market.prepareTrade({ targetMean: 105 });
|
|
48
|
+
* await account.execute(toRpcCalls(trade.calls));
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function toRpcCalls(calls) {
|
|
52
|
+
return calls.map(toRpcCall);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=call-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-format.js","sourceRoot":"","sources":["../../src/utils/call-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO;QACL,gBAAgB,EAAE,IAAI,CAAC,eAAe;QACtC,WAAW,EAAE,IAAI,CAAC,UAAU;QAC5B,QAAQ,EAAG,IAAI,CAAC,QAAqB,IAAI,EAAE;KAC5C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { DECIMALS_6, DECIMALS_18, fromTokenAmount, toTokenAmountDown, toTokenAmountUp, } from './decimal-scale';
|
|
7
7
|
export { buildApproveCall } from './erc20';
|
|
8
|
+
export { type CallRpc, toRpcCall, toRpcCalls } from './call-format';
|
|
8
9
|
export { normalizeResponse, snakeToCamel } from './normalize';
|
|
9
10
|
export { SQRT_PI, SQRT_PI_SQ, sqrtSQ128x128 } from './math';
|
|
10
11
|
export { computeBackingDenomHint, computeBackingDenomHintNumber, computeHints, computeHintsFromNumber, computeL2NormDenomHint, computeL2NormDenomHintNumber, } from './hints';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5D,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,kBAAkB,EAClB,aAAa,EACb,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,KAAK,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5D,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,kBAAkB,EAClB,aAAa,EACb,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { DECIMALS_6, DECIMALS_18, fromTokenAmount, toTokenAmountDown, toTokenAmountUp, } from './decimal-scale';
|
|
7
7
|
export { buildApproveCall } from './erc20';
|
|
8
|
+
export { toRpcCall, toRpcCalls } from './call-format';
|
|
8
9
|
export { normalizeResponse, snakeToCamel } from './normalize';
|
|
9
10
|
export { SQRT_PI, SQRT_PI_SQ, sqrtSQ128x128 } from './math';
|
|
10
11
|
export { computeBackingDenomHint, computeBackingDenomHintNumber, computeHints, computeHintsFromNumber, computeL2NormDenomHint, computeL2NormDenomHintNumber, } from './hints';
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,iBAA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