@layerzerolabs/onesig-stellar-sdk 0.2.133 → 1.2.7

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.
@@ -4,7 +4,7 @@ import { Address, StrKey } from '@stellar/stellar-sdk';
4
4
 
5
5
  var ONE_SIG_SPEC = new Client({
6
6
  contractId: "",
7
- rpcUrl: "",
7
+ rpcUrl: "http://localhost",
8
8
  networkPassphrase: "",
9
9
  allowHttp: true
10
10
  }).spec;
@@ -47,5 +47,5 @@ function stellarLeafGenerator(leafs) {
47
47
  __name(stellarLeafGenerator, "stellarLeafGenerator");
48
48
 
49
49
  export { stellarLeafGenerator };
50
- //# sourceMappingURL=IJZY3WB2.mjs.map
51
- //# sourceMappingURL=IJZY3WB2.mjs.map
50
+ //# sourceMappingURL=CT3BLMHC.mjs.map
51
+ //# sourceMappingURL=CT3BLMHC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/leafGenerator.ts"],"names":["ONE_SIG_SPEC","Client","contractId","rpcUrl","networkPassphrase","allowHttp","spec","callInput","getFunc","inputs","find","input","name","toString","Error","CALL_TYPE","type","stellarLeafGenerator","leafs","encodeAddress","address","StrKey","decodeContract","encodeCalls","calls","length","call","callObject","to","Address","fromString","contractAddress","func","functionName","args","sub_invocations","nativeToScVal","toXDR"],"mappings":";;;;AAWA,IAAMA,YAAAA,GAAe,IAAIC,MAAAA,CAAO;EAC5BC,UAAAA,EAAY,EAAA;EACZC,MAAAA,EAAQ,kBAAA;EACRC,iBAAAA,EAAmB,EAAA;EACnBC,SAAAA,EAAW;AACf,CAAA,CAAA,CAAGC,IAAAA;AACH,IAAMC,SAAAA,GAAYP,YAAAA,CAAaQ,OAAAA,CAAQ,aAAA,EAClCC,MAAAA,EAAM,CACNC,IAAAA,CAAK,CAACC,UAAqCA,KAAAA,CAAMC,IAAAA,EAAI,CAAGC,QAAAA,OAAe,MAAA,CAAA;AAC5E,IAAI,CAACN,SAAAA,EAAW,MAAM,IAAIO,MAAM,uDAAA,CAAA;AAChC,IAAMC,SAAAA,GAAYR,UAAUS,IAAAA,EAAI;AA4BzB,SAASC,qBACZC,KAAAA,EAAwB;AAExB,EAAA,OAAO;AACHA,IAAAA,KAAAA;;AAGAC,IAAAA,aAAAA,CAAcC,OAAAA,EAAe;AACzB,MAAA,IAAI;AACA,QAAA,OAAOC,MAAAA,CAAOC,eAAeF,OAAAA,CAAAA;MACjC,CAAA,CAAA,MAAQ;AACJ,QAAA,MAAM,IAAIN,KAAAA,CAAM,CAAA,iCAAA,EAAoCM,OAAAA,CAAAA,gBAAAA,CAAyB,CAAA;AACjF,MAAA;AACJ,IAAA,CAAA;;;;;;;;AASAG,IAAAA,WAAAA,CAAYC,KAAAA,EAAoB;AAC5B,MAAA,IAAIA,KAAAA,CAAMC,WAAW,CAAA,EAAG;AACpB,QAAA,MAAM,IAAIX,MACN,sIACI,CAAA;AAEZ,MAAA;AAEA,MAAA,MAAMY,IAAAA,GAAOF,MAAM,CAAA,CAAA;AACnB,MAAA,MAAMG,UAAAA,GAAa;QACfC,EAAAA,EAAIC,OAAAA,CAAQC,UAAAA,CAAWJ,IAAAA,CAAKK,eAAe,CAAA;AAC3CC,QAAAA,IAAAA,EAAMN,IAAAA,CAAKO,YAAAA;AACXC,QAAAA,IAAAA,EAAMR,IAAAA,CAAKQ,IAAAA;AACXC,QAAAA,eAAAA,EAAiB;AACrB,OAAA;AAEA,MAAA,OAAOnC,YAAAA,CAAaoC,aAAAA,CAAcT,UAAAA,EAAYZ,SAAAA,EAAWsB,KAAAA,EAAK;AAClE,IAAA;AACJ,GAAA;AACJ;AAzCgBpB,MAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA","file":"CT3BLMHC.mjs","sourcesContent":["import type { xdr } from '@stellar/stellar-sdk';\nimport { Address, StrKey } from '@stellar/stellar-sdk';\n\nimport { type BaseLeafData, type GenerateLeafsResult } from '@layerzerolabs/onesig-core';\n\nimport { Client } from './generated/index';\n\n// Get the contract spec and Call type at module load. Only `.spec` is used here (no\n// network call), but stellar-sdk v16 eagerly builds an RpcServer in the Client\n// constructor and validates `rpcUrl` via `new URL(...)`, so an empty string throws\n// \"Invalid URL\". Pass a syntactically valid placeholder instead.\nconst ONE_SIG_SPEC = new Client({\n contractId: '',\n rpcUrl: 'http://localhost',\n networkPassphrase: '',\n allowHttp: true,\n}).spec;\nconst callInput = ONE_SIG_SPEC.getFunc('encode_leaf')\n .inputs()\n .find((input: xdr.ScSpecFunctionInputV0) => input.name().toString() === 'call');\nif (!callInput) throw new Error('Could not find call parameter in encode_leaf function');\nconst CALL_TYPE = callInput.type();\n\n/**\n * Stellar contract call data structure\n *\n * Arguments are provided as pre-encoded ScVal[] matching the contract function's parameter types.\n * The entire Call struct (to, func, args) is encoded using nativeToScVal for XDR encoding.\n *\n * A OneSig merkle leaf authorizes exactly ONE self-call on the OneSig contract\n * (see `encodeCalls`, which rejects more than one). This is not a multicall type:\n * each `StellarCall` is a single `(contract, function, args)` invocation.\n *\n * To execute multiple calls under one leaf, you do NOT pass several `StellarCall`s.\n * Instead you make a single `execute_transaction` self-call and put the batch of\n * calls *inside* its `args`: the `calls: Vec<Call>` parameter carries them, and the\n * OneSig contract dispatches each in turn. Use `createExecuteTransactionCall` to\n * build that wrapper. So multicall lives one level down — in the `args` of a single\n * `execute_transaction` call — not in the number of `StellarCall`s per leaf.\n */\nexport interface StellarCall {\n contractAddress: string; // Soroban contract address (C...)\n functionName: string; // Function name to call\n args: xdr.ScVal[]; // Function arguments as ScVal[] matching contract parameters\n}\n\nexport type StellarLeafData = BaseLeafData<string, StellarCall>;\n\n/** Generates Stellar leaf data for OneSig Merkle tree */\nexport function stellarLeafGenerator(\n leafs: StellarLeafData[],\n): GenerateLeafsResult<StellarLeafData> {\n return {\n leafs,\n\n /** Encode OneSig contract address (C...) to 32-byte buffer */\n encodeAddress(address: string): Buffer {\n try {\n return StrKey.decodeContract(address);\n } catch {\n throw new Error(`Invalid OneSig contract address: ${address}. Expected: C...`);\n }\n },\n\n /**\n * Encode a single self-call to XDR buffer using Call encoding.\n *\n * Each leaf contains exactly one self-call (e.g. `set_seed`, `execute_transaction`).\n * To dispatch multiple external contract calls, use a single `execute_transaction`\n * call whose args carry the list of external calls.\n */\n encodeCalls(calls: StellarCall[]): Buffer {\n if (calls.length !== 1) {\n throw new Error(\n 'Stellar leaf must have exactly one self-call. ' +\n 'For multiple external calls, use execute_transaction whose args contain the call list.',\n );\n }\n\n const call = calls[0];\n const callObject = {\n to: Address.fromString(call.contractAddress),\n func: call.functionName,\n args: call.args,\n sub_invocations: [],\n };\n\n return ONE_SIG_SPEC.nativeToScVal(callObject, CALL_TYPE).toXDR();\n },\n };\n}\n"]}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { generateStellarConfigChangeCall } from './EJZMSFN5.mjs';
2
2
  export { createExecuteTransactionCall, createSetExecutorCall, createSetExecutorRequiredCall, createSetSeedCall, createSetSignerCall, createSetThresholdCall } from './DPYAZNJF.mjs';
3
- export { stellarLeafGenerator } from './IJZY3WB2.mjs';
3
+ export { stellarLeafGenerator } from './CT3BLMHC.mjs';
4
4
  export { AuthError, BufferReaderError, BufferWriterError, BytesExtError, Client, MultiSigError, OneSigError, OwnableError, RbacError, TtlConfigurableError, UpgradeableError, WASM_BASE64, WASM_HASH, contract, getWasmBuffer, rpc } from './NQUQ5475.mjs';
5
5
  import './YYM473VY.mjs';
6
6
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"leafGenerator.d.ts","sourceRoot":"","sources":["../src/leafGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAiBzF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEhE,yDAAyD;AACzD,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,eAAe,EAAE,GACzB,mBAAmB,CAAC,eAAe,CAAC,CAuCtC"}
1
+ {"version":3,"file":"leafGenerator.d.ts","sourceRoot":"","sources":["../src/leafGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAoBzF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEhE,yDAAyD;AACzD,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,eAAe,EAAE,GACzB,mBAAmB,CAAC,eAAe,CAAC,CAuCtC"}
@@ -1,4 +1,4 @@
1
- export { stellarLeafGenerator } from './IJZY3WB2.mjs';
1
+ export { stellarLeafGenerator } from './CT3BLMHC.mjs';
2
2
  import './NQUQ5475.mjs';
3
3
  import './YYM473VY.mjs';
4
4
  //# sourceMappingURL=leafGenerator.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/onesig-stellar-sdk",
3
- "version": "0.2.133",
3
+ "version": "1.2.7",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK for OneSig Stellar contract",
6
6
  "license": "MIT",
@@ -17,10 +17,10 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@stellar/stellar-sdk": "^14.4.3",
21
- "@layerzerolabs/onesig-core": "0.2.133",
22
- "@layerzerolabs/common-encoding-utils": "0.2.133",
23
- "@layerzerolabs/onesig-model": "0.2.133"
20
+ "@stellar/stellar-sdk": "^16.0.1",
21
+ "@layerzerolabs/common-encoding-utils": "1.2.7",
22
+ "@layerzerolabs/onesig-model": "1.2.7",
23
+ "@layerzerolabs/onesig-core": "1.2.7"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.18.6",
@@ -29,11 +29,11 @@
29
29
  "tsx": "^4.21.0",
30
30
  "typescript": "^5.8.2",
31
31
  "vitest": "^3.2.6",
32
- "@layerzerolabs/onesig-stellar-contracts": "0.2.133",
33
- "@layerzerolabs/stellar-ts-bindings-gen": "0.2.133",
34
- "@layerzerolabs/vm-tooling-stellar": "0.2.133",
35
- "@layerzerolabs/typescript-configuration": "0.2.133",
36
- "@layerzerolabs/tsup-configuration": "0.2.133"
32
+ "@layerzerolabs/onesig-stellar-contracts": "1.2.7",
33
+ "@layerzerolabs/stellar-ts-bindings-gen": "1.2.7",
34
+ "@layerzerolabs/tsup-configuration": "1.2.7",
35
+ "@layerzerolabs/typescript-configuration": "1.2.7",
36
+ "@layerzerolabs/vm-tooling-stellar": "1.2.7"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/leafGenerator.ts"],"names":["ONE_SIG_SPEC","Client","contractId","rpcUrl","networkPassphrase","allowHttp","spec","callInput","getFunc","inputs","find","input","name","toString","Error","CALL_TYPE","type","stellarLeafGenerator","leafs","encodeAddress","address","StrKey","decodeContract","encodeCalls","calls","length","call","callObject","to","Address","fromString","contractAddress","func","functionName","args","sub_invocations","nativeToScVal","toXDR"],"mappings":";;;;AAQA,IAAMA,YAAAA,GAAe,IAAIC,MAAAA,CAAO;EAC5BC,UAAAA,EAAY,EAAA;EACZC,MAAAA,EAAQ,EAAA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EAAYZ,SAAAA,EAAWsB,KAAAA,EAAK;AAClE,IAAA;AACJ,GAAA;AACJ;AAzCgBpB,MAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA","file":"IJZY3WB2.mjs","sourcesContent":["import type { xdr } from '@stellar/stellar-sdk';\nimport { Address, StrKey } from '@stellar/stellar-sdk';\n\nimport { type BaseLeafData, type GenerateLeafsResult } from '@layerzerolabs/onesig-core';\n\nimport { Client } from './generated/index';\n\n// Get the contract spec and Call type at module load\nconst ONE_SIG_SPEC = new Client({\n contractId: '',\n rpcUrl: '',\n networkPassphrase: '',\n allowHttp: true,\n}).spec;\nconst callInput = ONE_SIG_SPEC.getFunc('encode_leaf')\n .inputs()\n .find((input: xdr.ScSpecFunctionInputV0) => input.name().toString() === 'call');\nif (!callInput) throw new Error('Could not find call parameter in encode_leaf function');\nconst CALL_TYPE = callInput.type();\n\n/**\n * Stellar contract call data structure\n *\n * Arguments are provided as pre-encoded ScVal[] matching the contract function's parameter types.\n * The entire Call struct (to, func, args) is encoded using nativeToScVal for XDR encoding.\n *\n * A OneSig merkle leaf authorizes exactly ONE self-call on the OneSig contract\n * (see `encodeCalls`, which rejects more than one). This is not a multicall type:\n * each `StellarCall` is a single `(contract, function, args)` invocation.\n *\n * To execute multiple calls under one leaf, you do NOT pass several `StellarCall`s.\n * Instead you make a single `execute_transaction` self-call and put the batch of\n * calls *inside* its `args`: the `calls: Vec<Call>` parameter carries them, and the\n * OneSig contract dispatches each in turn. Use `createExecuteTransactionCall` to\n * build that wrapper. So multicall lives one level down — in the `args` of a single\n * `execute_transaction` call — not in the number of `StellarCall`s per leaf.\n */\nexport interface StellarCall {\n contractAddress: string; // Soroban contract address (C...)\n functionName: string; // Function name to call\n args: xdr.ScVal[]; // Function arguments as ScVal[] matching contract parameters\n}\n\nexport type StellarLeafData = BaseLeafData<string, StellarCall>;\n\n/** Generates Stellar leaf data for OneSig Merkle tree */\nexport function stellarLeafGenerator(\n leafs: StellarLeafData[],\n): GenerateLeafsResult<StellarLeafData> {\n return {\n leafs,\n\n /** Encode OneSig contract address (C...) to 32-byte buffer */\n encodeAddress(address: string): Buffer {\n try {\n return StrKey.decodeContract(address);\n } catch {\n throw new Error(`Invalid OneSig contract address: ${address}. Expected: C...`);\n }\n },\n\n /**\n * Encode a single self-call to XDR buffer using Call encoding.\n *\n * Each leaf contains exactly one self-call (e.g. `set_seed`, `execute_transaction`).\n * To dispatch multiple external contract calls, use a single `execute_transaction`\n * call whose args carry the list of external calls.\n */\n encodeCalls(calls: StellarCall[]): Buffer {\n if (calls.length !== 1) {\n throw new Error(\n 'Stellar leaf must have exactly one self-call. ' +\n 'For multiple external calls, use execute_transaction whose args contain the call list.',\n );\n }\n\n const call = calls[0];\n const callObject = {\n to: Address.fromString(call.contractAddress),\n func: call.functionName,\n args: call.args,\n sub_invocations: [],\n };\n\n return ONE_SIG_SPEC.nativeToScVal(callObject, CALL_TYPE).toXDR();\n },\n };\n}\n"]}