@fastnear/utils 0.9.5 → 0.9.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.
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -29,15 +29,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  mod
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var src_exports = {};
33
- __export(src_exports, {
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
34
  exp: () => exp
35
35
  });
36
- module.exports = __toCommonJS(src_exports);
37
- __reExport(src_exports, require("./crypto.js"), module.exports);
38
- __reExport(src_exports, require("./transaction.js"), module.exports);
39
- __reExport(src_exports, require("./misc.js"), module.exports);
40
- __reExport(src_exports, require("./storage.js"), module.exports);
36
+ module.exports = __toCommonJS(index_exports);
37
+ __reExport(index_exports, require("./crypto.js"), module.exports);
38
+ __reExport(index_exports, require("./transaction.js"), module.exports);
39
+ __reExport(index_exports, require("./misc.js"), module.exports);
40
+ __reExport(index_exports, require("./storage.js"), module.exports);
41
41
  var import_borsh = require("borsh");
42
42
  var borshSchema = __toESM(require("@fastnear/borsh-schema"), 1);
43
43
  const exp = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./crypto.js\";\nexport * from \"./transaction.js\";\nexport * from \"./misc.js\";\nexport * from \"./storage.js\";\n\nimport { serialize, deserialize } from \"borsh\";\nimport * as borshSchema from \"@fastnear/borsh-schema\";\n\n// exports (or re-exports as well)\nconst exp = {\n borsh: {\n serialize,\n deserialize\n },\n borshSchema,\n}\n\nexport { exp }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,wBAAd;AACA,wBAAc,6BADd;AAEA,wBAAc,sBAFd;AAGA,wBAAc,yBAHd;AAKA,mBAAuC;AACvC,kBAA6B;AAG7B,MAAM,MAAM;AAAA,EACV,OAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./crypto.js\";\nexport * from \"./transaction.js\";\nexport * from \"./misc.js\";\nexport * from \"./storage.js\";\n\nimport { serialize, deserialize } from \"borsh\";\nimport * as borshSchema from \"@fastnear/borsh-schema\";\n\n// exports (or re-exports as well)\nconst exp = {\n borsh: {\n serialize,\n deserialize\n },\n borshSchema,\n}\n\nexport { exp }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,wBAAd;AACA,0BAAc,6BADd;AAEA,0BAAc,sBAFd;AAGA,0BAAc,yBAHd;AAKA,mBAAuC;AACvC,kBAA6B;AAG7B,MAAM,MAAM;AAAA,EACV,OAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AAAA,EACA;AACF;","names":[]}
package/dist/cjs/misc.cjs CHANGED
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - CJS (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -94,21 +94,17 @@ function mapAction(action) {
94
94
  case "DeployContract": {
95
95
  return {
96
96
  deployContract: {
97
- code: (0, import_misc.fromBase64)(action.codeBase64)
97
+ code: (0, import_misc.base64ToBytes)(action.codeBase64)
98
98
  }
99
99
  };
100
100
  }
101
101
  case "FunctionCall": {
102
- const argsAsString = JSON.stringify(action.args);
103
- const argsEncoded = new TextEncoder().encode(argsAsString);
104
- const defaultGas = BigInt("225000000000000");
105
- const defaultDeposit = BigInt("0");
106
102
  return {
107
103
  functionCall: {
108
104
  methodName: action.methodName,
109
- args: argsEncoded,
110
- gas: BigInt(action.gas ?? defaultGas),
111
- deposit: BigInt(action.deposit ?? defaultDeposit)
105
+ args: action.argsBase64 !== null && action.argsBase64 !== void 0 ? (0, import_misc.base64ToBytes)(action.argsBase64) : new TextEncoder().encode(JSON.stringify(action.args)),
106
+ gas: BigInt(action.gas ?? "300000000000000"),
107
+ deposit: BigInt(action.deposit ?? "0")
112
108
  }
113
109
  };
114
110
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transaction.ts"],"sourcesContent":["import { serialize as borshSerialize, deserialize as borshDeserialize, Schema } from \"borsh\";\nimport { keyFromString } from \"./crypto.js\";\nimport { fromBase58, fromBase64, toBase64 } from \"./misc.js\";\nimport { getBorshSchema } from \"@fastnear/borsh-schema\";\n\nexport interface PlainTransaction {\n signerId: string;\n publicKey: string;\n nonce: string | bigint | number;\n receiverId: string;\n blockHash: string;\n actions: Array<any>;\n}\n\nexport interface PlainSignedTransaction {\n transaction: object;\n signature: object;\n}\n\n// Function to return a JSON-ready version of the transaction\nexport const txToJson = (tx: PlainTransaction): Record<string, any> => {\n return JSON.parse(JSON.stringify(tx, (key, value) =>\n typeof value === 'bigint' ? value.toString() : value\n ));\n};\n\n// dude let's make this better. head just couldn't find a good name\nexport const txToJsonStringified = (tx: PlainTransaction): string => {\n return JSON.stringify(txToJson(tx));\n}\n\nexport function mapTransaction(jsonTransaction: PlainTransaction) {\n return {\n signerId: jsonTransaction.signerId,\n publicKey: {\n ed25519Key: {\n data: keyFromString(jsonTransaction.publicKey)\n }\n },\n nonce: BigInt(jsonTransaction.nonce),\n receiverId: jsonTransaction.receiverId,\n blockHash: fromBase58(jsonTransaction.blockHash),\n actions: jsonTransaction.actions.map(mapAction)\n };\n}\n\nexport function serializeTransaction(jsonTransaction: PlainTransaction) {\n console.log(\"fastnear: serializing transaction\");\n\n const transaction = mapTransaction(jsonTransaction);\n console.log(\"fastnear: mapped transaction for borsh:\", transaction);\n\n return borshSerialize(SCHEMA.Transaction, transaction);\n}\n\nexport function serializeSignedTransaction(jsonTransaction: PlainTransaction, signature) {\n console.log(\"fastnear: Serializing Signed Transaction\", jsonTransaction);\n console.log('fastnear: signature', signature)\n console.log('fastnear: signature length', fromBase58(signature).length)\n\n const mappedSignedTx = mapTransaction(jsonTransaction)\n console.log('fastnear: mapped (for borsh schema) signed transaction', mappedSignedTx)\n\n const plainSignedTransaction: PlainSignedTransaction = {\n transaction: mappedSignedTx,\n signature: {\n ed25519Signature: {\n data: fromBase58(signature),\n },\n },\n };\n\n const borshSignedTx = borshSerialize(SCHEMA.SignedTransaction, plainSignedTransaction, true);\n console.log('fastnear: borsh-serialized signed transaction:', borshSignedTx);\n\n return borshSignedTx;\n}\n\nexport function mapAction(action: any): object {\n switch (action.type) {\n case \"CreateAccount\": {\n return {\n createAccount: {},\n };\n }\n case \"DeployContract\": {\n return {\n deployContract: {\n code: fromBase64(action.codeBase64),\n },\n };\n }\n case \"FunctionCall\": {\n // turn JS object into json string\n const argsAsString = JSON.stringify(action.args)\n // an alternative to using NodeJS Buffer, TextEncoder can help but is limited\n const argsEncoded = new TextEncoder().encode(argsAsString)\n\n const defaultGas = BigInt(\"225000000000000\")\n const defaultDeposit = BigInt(\"0\")\n\n return {\n functionCall: {\n methodName: action.methodName,\n args: argsEncoded,\n gas: BigInt(action.gas ?? defaultGas),\n deposit: BigInt(action.deposit ?? defaultDeposit),\n },\n };\n }\n case \"Transfer\": {\n return {\n transfer: {\n deposit: BigInt(action.deposit),\n },\n };\n }\n case \"Stake\": {\n return {\n stake: {\n stake: BigInt(action.stake),\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"AddKey\": {\n return {\n addKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n accessKey: {\n nonce: BigInt(action.accessKey.nonce),\n permission:\n action.accessKey.permission === \"FullAccess\"\n ? { fullAccess: {} }\n : {\n functionCall: {\n allowance: action.accessKey.allowance\n ? BigInt(action.accessKey.allowance)\n : null,\n receiverId: action.accessKey.receiverId,\n methodNames: action.accessKey.methodNames,\n },\n },\n },\n },\n };\n }\n case \"DeleteKey\": {\n return {\n deleteKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"DeleteAccount\": {\n return {\n deleteAccount: {\n beneficiaryId: action.beneficiaryId,\n },\n };\n }\n case \"SignedDelegate\": {\n return {\n signedDelegate: {\n delegateAction: mapAction(action.delegateAction),\n signature: {\n ed25519Signature: fromBase58(action.signature),\n },\n },\n };\n }\n default: {\n throw new Error(\"Not implemented action: \" + action.type);\n }\n }\n}\n\nexport const SCHEMA = getBorshSchema();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqF;AACrF,oBAA8B;AAC9B,kBAAiD;AACjD,0BAA+B;AAiBxB,MAAM,WAAW,wBAAC,OAA8C;AACrE,SAAO,KAAK,MAAM,KAAK;AAAA,IAAU;AAAA,IAAI,CAAC,KAAK,UACzC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD,CAAC;AACH,GAJwB;AAOjB,MAAM,sBAAsB,wBAAC,OAAiC;AACnE,SAAO,KAAK,UAAU,SAAS,EAAE,CAAC;AACpC,GAFmC;AAI5B,SAAS,eAAe,iBAAmC;AAChE,SAAO;AAAA,IACL,UAAU,gBAAgB;AAAA,IAC1B,WAAW;AAAA,MACT,YAAY;AAAA,QACV,UAAM,6BAAc,gBAAgB,SAAS;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,OAAO,OAAO,gBAAgB,KAAK;AAAA,IACnC,YAAY,gBAAgB;AAAA,IAC5B,eAAW,wBAAW,gBAAgB,SAAS;AAAA,IAC/C,SAAS,gBAAgB,QAAQ,IAAI,SAAS;AAAA,EAChD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AAA,QACL,gBAAgB;AAAA,UACd,gBAAgB,UAAU,OAAO,cAAc;AAAA,UAC/C,WAAW;AAAA,YACT,sBAAkB,wBAAW,OAAO,SAAS;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AACP,YAAM,IAAI,MAAM,6BAA6B,OAAO,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AA7GgB;AA+GT,MAAM,aAAS,oCAAe;","names":["borshSerialize"]}
1
+ {"version":3,"sources":["../../src/transaction.ts"],"sourcesContent":["import { serialize as borshSerialize, deserialize as borshDeserialize, Schema } from \"borsh\";\nimport { keyFromString } from \"./crypto.js\";\nimport {base64ToBytes, fromBase58, fromBase64, toBase64} from \"./misc.js\";\nimport { getBorshSchema } from \"@fastnear/borsh-schema\";\n\nexport interface PlainTransaction {\n signerId: string;\n publicKey: string;\n nonce: string | bigint | number;\n receiverId: string;\n blockHash: string;\n actions: Array<any>;\n}\n\nexport interface PlainSignedTransaction {\n transaction: object;\n signature: object;\n}\n\n// Function to return a JSON-ready version of the transaction\nexport const txToJson = (tx: PlainTransaction): Record<string, any> => {\n return JSON.parse(JSON.stringify(tx, (key, value) =>\n typeof value === 'bigint' ? value.toString() : value\n ));\n};\n\n// dude let's make this better. head just couldn't find a good name\nexport const txToJsonStringified = (tx: PlainTransaction): string => {\n return JSON.stringify(txToJson(tx));\n}\n\nexport function mapTransaction(jsonTransaction: PlainTransaction) {\n return {\n signerId: jsonTransaction.signerId,\n publicKey: {\n ed25519Key: {\n data: keyFromString(jsonTransaction.publicKey)\n }\n },\n nonce: BigInt(jsonTransaction.nonce),\n receiverId: jsonTransaction.receiverId,\n blockHash: fromBase58(jsonTransaction.blockHash),\n actions: jsonTransaction.actions.map(mapAction)\n };\n}\n\nexport function serializeTransaction(jsonTransaction: PlainTransaction) {\n console.log(\"fastnear: serializing transaction\");\n\n const transaction = mapTransaction(jsonTransaction);\n console.log(\"fastnear: mapped transaction for borsh:\", transaction);\n\n return borshSerialize(SCHEMA.Transaction, transaction);\n}\n\nexport function serializeSignedTransaction(jsonTransaction: PlainTransaction, signature) {\n console.log(\"fastnear: Serializing Signed Transaction\", jsonTransaction);\n console.log('fastnear: signature', signature)\n console.log('fastnear: signature length', fromBase58(signature).length)\n\n const mappedSignedTx = mapTransaction(jsonTransaction)\n console.log('fastnear: mapped (for borsh schema) signed transaction', mappedSignedTx)\n\n const plainSignedTransaction: PlainSignedTransaction = {\n transaction: mappedSignedTx,\n signature: {\n ed25519Signature: {\n data: fromBase58(signature),\n },\n },\n };\n\n const borshSignedTx = borshSerialize(SCHEMA.SignedTransaction, plainSignedTransaction, true);\n console.log('fastnear: borsh-serialized signed transaction:', borshSignedTx);\n\n return borshSignedTx;\n}\n\nexport function mapAction(action: any): object {\n switch (action.type) {\n case \"CreateAccount\": {\n return {\n createAccount: {},\n };\n }\n case \"DeployContract\": {\n return {\n deployContract: {\n code: base64ToBytes(action.codeBase64),\n },\n };\n }\n case \"FunctionCall\": {\n return {\n functionCall: {\n methodName: action.methodName,\n args: (action.argsBase64 !== null && action.argsBase64 !== undefined) ?\n base64ToBytes(action.argsBase64) :\n (new TextEncoder().encode(JSON.stringify(action.args))),\n gas: BigInt(action.gas ?? \"300000000000000\"),\n deposit: BigInt(action.deposit ?? \"0\"),\n },\n };\n }\n case \"Transfer\": {\n return {\n transfer: {\n deposit: BigInt(action.deposit),\n },\n };\n }\n case \"Stake\": {\n return {\n stake: {\n stake: BigInt(action.stake),\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"AddKey\": {\n return {\n addKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n accessKey: {\n nonce: BigInt(action.accessKey.nonce),\n permission:\n action.accessKey.permission === \"FullAccess\"\n ? { fullAccess: {} }\n : {\n functionCall: {\n allowance: action.accessKey.allowance\n ? BigInt(action.accessKey.allowance)\n : null,\n receiverId: action.accessKey.receiverId,\n methodNames: action.accessKey.methodNames,\n },\n },\n },\n },\n };\n }\n case \"DeleteKey\": {\n return {\n deleteKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"DeleteAccount\": {\n return {\n deleteAccount: {\n beneficiaryId: action.beneficiaryId,\n },\n };\n }\n case \"SignedDelegate\": {\n return {\n signedDelegate: {\n delegateAction: mapAction(action.delegateAction),\n signature: {\n ed25519Signature: fromBase58(action.signature),\n },\n },\n };\n }\n default: {\n throw new Error(\"Not implemented action: \" + action.type);\n }\n }\n}\n\nexport const SCHEMA = getBorshSchema();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqF;AACrF,oBAA8B;AAC9B,kBAA8D;AAC9D,0BAA+B;AAiBxB,MAAM,WAAW,wBAAC,OAA8C;AACrE,SAAO,KAAK,MAAM,KAAK;AAAA,IAAU;AAAA,IAAI,CAAC,KAAK,UACzC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD,CAAC;AACH,GAJwB;AAOjB,MAAM,sBAAsB,wBAAC,OAAiC;AACnE,SAAO,KAAK,UAAU,SAAS,EAAE,CAAC;AACpC,GAFmC;AAI5B,SAAS,eAAe,iBAAmC;AAChE,SAAO;AAAA,IACL,UAAU,gBAAgB;AAAA,IAC1B,WAAW;AAAA,MACT,YAAY;AAAA,QACV,UAAM,6BAAc,gBAAgB,SAAS;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,OAAO,OAAO,gBAAgB,KAAK;AAAA,IACnC,YAAY,gBAAgB;AAAA,IAC5B,eAAW,wBAAW,gBAAgB,SAAS;AAAA,IAC/C,SAAS,gBAAgB,QAAQ,IAAI,SAAS;AAAA,EAChD;AACF;AAbgB;AAeT,SAAS,qBAAqB,iBAAmC;AACtE,UAAQ,IAAI,mCAAmC;AAE/C,QAAM,cAAc,eAAe,eAA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AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AACP,YAAM,IAAI,MAAM,6BAA6B,OAAO,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAvGgB;AAyGT,MAAM,aAAS,oCAAe;","names":["borshSerialize"]}
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
  import { ed25519 } from "@noble/curves/ed25519";
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  export * from "./crypto.js";
4
4
  export * from "./transaction.js";
5
5
  export * from "./misc.js";
package/dist/esm/misc.js CHANGED
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
  import {
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
  const LsPrefix = "__fastnear_";
@@ -1,10 +1,10 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - ESM (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
  import { serialize as borshSerialize } from "borsh";
6
6
  import { keyFromString } from "./crypto.js";
7
- import { fromBase58, fromBase64 } from "./misc.js";
7
+ import { base64ToBytes, fromBase58 } from "./misc.js";
8
8
  import { getBorshSchema } from "@fastnear/borsh-schema";
9
9
  const txToJson = /* @__PURE__ */ __name((tx) => {
10
10
  return JSON.parse(JSON.stringify(
@@ -66,21 +66,17 @@ function mapAction(action) {
66
66
  case "DeployContract": {
67
67
  return {
68
68
  deployContract: {
69
- code: fromBase64(action.codeBase64)
69
+ code: base64ToBytes(action.codeBase64)
70
70
  }
71
71
  };
72
72
  }
73
73
  case "FunctionCall": {
74
- const argsAsString = JSON.stringify(action.args);
75
- const argsEncoded = new TextEncoder().encode(argsAsString);
76
- const defaultGas = BigInt("225000000000000");
77
- const defaultDeposit = BigInt("0");
78
74
  return {
79
75
  functionCall: {
80
76
  methodName: action.methodName,
81
- args: argsEncoded,
82
- gas: BigInt(action.gas ?? defaultGas),
83
- deposit: BigInt(action.deposit ?? defaultDeposit)
77
+ args: action.argsBase64 !== null && action.argsBase64 !== void 0 ? base64ToBytes(action.argsBase64) : new TextEncoder().encode(JSON.stringify(action.args)),
78
+ gas: BigInt(action.gas ?? "300000000000000"),
79
+ deposit: BigInt(action.deposit ?? "0")
84
80
  }
85
81
  };
86
82
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transaction.ts"],"sourcesContent":["import { serialize as borshSerialize, deserialize as borshDeserialize, Schema } from \"borsh\";\nimport { keyFromString } from \"./crypto.js\";\nimport { fromBase58, fromBase64, toBase64 } from \"./misc.js\";\nimport { getBorshSchema } from \"@fastnear/borsh-schema\";\n\nexport interface PlainTransaction {\n signerId: string;\n publicKey: string;\n nonce: string | bigint | number;\n receiverId: string;\n blockHash: string;\n actions: Array<any>;\n}\n\nexport interface PlainSignedTransaction {\n transaction: object;\n signature: object;\n}\n\n// Function to return a JSON-ready version of the transaction\nexport const txToJson = (tx: PlainTransaction): Record<string, any> => {\n return JSON.parse(JSON.stringify(tx, (key, value) =>\n typeof value === 'bigint' ? value.toString() : value\n ));\n};\n\n// dude let's make this better. head just couldn't find a good name\nexport const txToJsonStringified = (tx: PlainTransaction): string => {\n return JSON.stringify(txToJson(tx));\n}\n\nexport function mapTransaction(jsonTransaction: PlainTransaction) {\n return {\n signerId: jsonTransaction.signerId,\n publicKey: {\n ed25519Key: {\n data: keyFromString(jsonTransaction.publicKey)\n }\n },\n nonce: BigInt(jsonTransaction.nonce),\n receiverId: jsonTransaction.receiverId,\n blockHash: fromBase58(jsonTransaction.blockHash),\n actions: jsonTransaction.actions.map(mapAction)\n };\n}\n\nexport function serializeTransaction(jsonTransaction: PlainTransaction) {\n console.log(\"fastnear: serializing transaction\");\n\n const transaction = mapTransaction(jsonTransaction);\n console.log(\"fastnear: mapped transaction for borsh:\", transaction);\n\n return borshSerialize(SCHEMA.Transaction, transaction);\n}\n\nexport function serializeSignedTransaction(jsonTransaction: PlainTransaction, signature) {\n console.log(\"fastnear: Serializing Signed Transaction\", jsonTransaction);\n console.log('fastnear: signature', signature)\n console.log('fastnear: signature length', fromBase58(signature).length)\n\n const mappedSignedTx = mapTransaction(jsonTransaction)\n console.log('fastnear: mapped (for borsh schema) signed transaction', mappedSignedTx)\n\n const plainSignedTransaction: PlainSignedTransaction = {\n transaction: mappedSignedTx,\n signature: {\n ed25519Signature: {\n data: fromBase58(signature),\n },\n },\n };\n\n const borshSignedTx = borshSerialize(SCHEMA.SignedTransaction, plainSignedTransaction, true);\n console.log('fastnear: borsh-serialized signed transaction:', borshSignedTx);\n\n return borshSignedTx;\n}\n\nexport function mapAction(action: any): object {\n switch (action.type) {\n case \"CreateAccount\": {\n return {\n createAccount: {},\n };\n }\n case \"DeployContract\": {\n return {\n deployContract: {\n code: fromBase64(action.codeBase64),\n },\n };\n }\n case \"FunctionCall\": {\n // turn JS object into json string\n const argsAsString = JSON.stringify(action.args)\n // an alternative to using NodeJS Buffer, TextEncoder can help but is limited\n const argsEncoded = new TextEncoder().encode(argsAsString)\n\n const defaultGas = BigInt(\"225000000000000\")\n const defaultDeposit = BigInt(\"0\")\n\n return {\n functionCall: {\n methodName: action.methodName,\n args: argsEncoded,\n gas: BigInt(action.gas ?? defaultGas),\n deposit: BigInt(action.deposit ?? defaultDeposit),\n },\n };\n }\n case \"Transfer\": {\n return {\n transfer: {\n deposit: BigInt(action.deposit),\n },\n };\n }\n case \"Stake\": {\n return {\n stake: {\n stake: BigInt(action.stake),\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"AddKey\": {\n return {\n addKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n accessKey: {\n nonce: BigInt(action.accessKey.nonce),\n permission:\n action.accessKey.permission === \"FullAccess\"\n ? { fullAccess: {} }\n : {\n functionCall: {\n allowance: action.accessKey.allowance\n ? BigInt(action.accessKey.allowance)\n : null,\n receiverId: action.accessKey.receiverId,\n methodNames: action.accessKey.methodNames,\n },\n },\n },\n },\n };\n }\n case \"DeleteKey\": {\n return {\n deleteKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"DeleteAccount\": {\n return {\n deleteAccount: {\n beneficiaryId: action.beneficiaryId,\n },\n };\n }\n case \"SignedDelegate\": {\n return {\n signedDelegate: {\n delegateAction: mapAction(action.delegateAction),\n signature: {\n ed25519Signature: fromBase58(action.signature),\n },\n },\n };\n }\n default: {\n throw new Error(\"Not implemented action: \" + action.type);\n }\n }\n}\n\nexport const SCHEMA = getBorshSchema();\n"],"mappings":";;;;AAAA,SAAS,aAAa,sBAA+D;AACrF,SAAS,qBAAqB;AAC9B,SAAS,YAAY,kBAA4B;AACjD,SAAS,sBAAsB;AAiBxB,MAAM,WAAW,wBAAC,OAA8C;AACrE,SAAO,KAAK,MAAM,KAAK;AAAA,IAAU;AAAA,IAAI,CAAC,KAAK,UACzC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD,CAAC;AACH,GAJwB;AAOjB,MAAM,sBAAsB,wBAAC,OAAiC;AACnE,SAAO,KAAK,UAAU,SAAS,EAAE,CAAC;AACpC,GAFmC;AAI5B,SAAS,eAAe,iBAAmC;AAChE,SAAO;AAAA,IACL,UAAU,gBAAgB;AAAA,IAC1B,WAAW;AAAA,MACT,YAAY;AAAA,QACV,MAAM,cAAc,gBAAgB,SAAS;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,OAAO,OAAO,gBAAgB,KAAK;AAAA,IACnC,YAAY,gBAAgB;AAAA,IAC5B,WAAW,WAAW,gBAAgB,SAAS;AAAA,IAC/C,SAAS,gBAAgB,QAAQ,IAAI,SAAS;AAAA,EAChD;AACF;AAbgB;AAeT,SAAS,qBAAqB,iBAAmC;AACtE,UAAQ,IAAI,mCAAmC;AAE/C,QAAM,cAAc,eAAe,eAAe;AAClD,UAAQ,IAAI,2CAA2C,WAAW;AAElE,SAAO,eAAe,OAAO,aAAa,WAAW;AACvD;AAPgB;AAST,SAAS,2BAA2B,iBAAmC,WAAW;AACvF,UAAQ,IAA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A+GT,MAAM,SAAS,eAAe;","names":[]}
1
+ {"version":3,"sources":["../../src/transaction.ts"],"sourcesContent":["import { serialize as borshSerialize, deserialize as borshDeserialize, Schema } from \"borsh\";\nimport { keyFromString } from \"./crypto.js\";\nimport {base64ToBytes, fromBase58, fromBase64, toBase64} from \"./misc.js\";\nimport { getBorshSchema } from \"@fastnear/borsh-schema\";\n\nexport interface PlainTransaction {\n signerId: string;\n publicKey: string;\n nonce: string | bigint | number;\n receiverId: string;\n blockHash: string;\n actions: Array<any>;\n}\n\nexport interface PlainSignedTransaction {\n transaction: object;\n signature: object;\n}\n\n// Function to return a JSON-ready version of the transaction\nexport const txToJson = (tx: PlainTransaction): Record<string, any> => {\n return JSON.parse(JSON.stringify(tx, (key, value) =>\n typeof value === 'bigint' ? value.toString() : value\n ));\n};\n\n// dude let's make this better. head just couldn't find a good name\nexport const txToJsonStringified = (tx: PlainTransaction): string => {\n return JSON.stringify(txToJson(tx));\n}\n\nexport function mapTransaction(jsonTransaction: PlainTransaction) {\n return {\n signerId: jsonTransaction.signerId,\n publicKey: {\n ed25519Key: {\n data: keyFromString(jsonTransaction.publicKey)\n }\n },\n nonce: BigInt(jsonTransaction.nonce),\n receiverId: jsonTransaction.receiverId,\n blockHash: fromBase58(jsonTransaction.blockHash),\n actions: jsonTransaction.actions.map(mapAction)\n };\n}\n\nexport function serializeTransaction(jsonTransaction: PlainTransaction) {\n console.log(\"fastnear: serializing transaction\");\n\n const transaction = mapTransaction(jsonTransaction);\n console.log(\"fastnear: mapped transaction for borsh:\", transaction);\n\n return borshSerialize(SCHEMA.Transaction, transaction);\n}\n\nexport function serializeSignedTransaction(jsonTransaction: PlainTransaction, signature) {\n console.log(\"fastnear: Serializing Signed Transaction\", jsonTransaction);\n console.log('fastnear: signature', signature)\n console.log('fastnear: signature length', fromBase58(signature).length)\n\n const mappedSignedTx = mapTransaction(jsonTransaction)\n console.log('fastnear: mapped (for borsh schema) signed transaction', mappedSignedTx)\n\n const plainSignedTransaction: PlainSignedTransaction = {\n transaction: mappedSignedTx,\n signature: {\n ed25519Signature: {\n data: fromBase58(signature),\n },\n },\n };\n\n const borshSignedTx = borshSerialize(SCHEMA.SignedTransaction, plainSignedTransaction, true);\n console.log('fastnear: borsh-serialized signed transaction:', borshSignedTx);\n\n return borshSignedTx;\n}\n\nexport function mapAction(action: any): object {\n switch (action.type) {\n case \"CreateAccount\": {\n return {\n createAccount: {},\n };\n }\n case \"DeployContract\": {\n return {\n deployContract: {\n code: base64ToBytes(action.codeBase64),\n },\n };\n }\n case \"FunctionCall\": {\n return {\n functionCall: {\n methodName: action.methodName,\n args: (action.argsBase64 !== null && action.argsBase64 !== undefined) ?\n base64ToBytes(action.argsBase64) :\n (new TextEncoder().encode(JSON.stringify(action.args))),\n gas: BigInt(action.gas ?? \"300000000000000\"),\n deposit: BigInt(action.deposit ?? \"0\"),\n },\n };\n }\n case \"Transfer\": {\n return {\n transfer: {\n deposit: BigInt(action.deposit),\n },\n };\n }\n case \"Stake\": {\n return {\n stake: {\n stake: BigInt(action.stake),\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"AddKey\": {\n return {\n addKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n accessKey: {\n nonce: BigInt(action.accessKey.nonce),\n permission:\n action.accessKey.permission === \"FullAccess\"\n ? { fullAccess: {} }\n : {\n functionCall: {\n allowance: action.accessKey.allowance\n ? BigInt(action.accessKey.allowance)\n : null,\n receiverId: action.accessKey.receiverId,\n methodNames: action.accessKey.methodNames,\n },\n },\n },\n },\n };\n }\n case \"DeleteKey\": {\n return {\n deleteKey: {\n publicKey: {\n ed25519Key: {\n data: keyFromString(action.publicKey),\n },\n },\n },\n };\n }\n case \"DeleteAccount\": {\n return {\n deleteAccount: {\n beneficiaryId: action.beneficiaryId,\n },\n };\n }\n case \"SignedDelegate\": {\n return {\n signedDelegate: {\n delegateAction: mapAction(action.delegateAction),\n signature: {\n ed25519Signature: fromBase58(action.signature),\n },\n },\n };\n }\n default: {\n throw new Error(\"Not implemented action: \" + action.type);\n }\n }\n}\n\nexport const SCHEMA = getBorshSchema();\n"],"mappings":";;;;AAAA,SAAS,aAAa,sBAA+D;AACrF,SAAS,qBAAqB;AAC9B,SAAQ,eAAe,kBAAuC;AAC9D,SAAS,sBAAsB;AAiBxB,MAAM,WAAW,wBAAC,OAA8C;AACrE,SAAO,KAAK,MAAM,KAAK;AAAA,IAAU;AAAA,IAAI,CAAC,KAAK,UACzC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD,CAAC;AACH,GAJwB;AAOjB,MAAM,sBAAsB,wBAAC,OAAiC;AACnE,SAAO,KAAK,UAAU,SAAS,EAAE,CAAC;AACpC,GAFmC;AAI5B,SAAS,eAAe,iBAAmC;AAChE,SAAO;AAAA,IACL,UAAU,gBAAgB;AAAA,IAC1B,WAAW;AAAA,MACT,YAAY;AAAA,QACV,MAAM,cAAc,gBAAgB,SAAS;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,OAAO,OAAO,gBAAgB,KAAK;AAAA,IACnC,YAAY,gBAAgB;AAAA,IAC5B,WAAW,WAAW,gBAAgB,SAAS;AAAA,IAC/C,SAAS,gBAAgB,QAAQ,IAAI,SAAS;AAAA,EAChD;AACF;AAbgB;AAeT,SAAS,qBAAqB,iBAAmC;AACtE,UAAQ,IAAI,mCAAmC;AAE/C,QAAM,cAAc,eAAe,eAAe;AAClD,UAAQ,IAAI,2CAA2C,WAAW;AAElE,SAAO,eAAe,OAAO,aAAa,WAAW;AACvD;AAPgB;AAST,SAAS,2BAA2B,iBAAmC,WAAW;AACvF,UAAQ,IAAI,4CAA4C,eAAe;AACvE,UAAQ,IAAI,uBAAuB,SAAS;AAC5C,UAAQ,IAAI,8BAA8B,WAAW,SAAS,EAAE,MAAM;AAEtE,QAAM,iBAAiB,eAAe,eAAe;AACrD,UAAQ,IAAI,0DAA0D,cAAc;AAEpF,QAAM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ACN,WAAW;AAAA,YACT,YAAY;AAAA,cACV,MAAM,cAAc,OAAO,SAAS;AAAA,YACtC;AAAA,UACF;AAAA,UACA,WAAW;AAAA,YACT,OAAO,OAAO,OAAO,UAAU,KAAK;AAAA,YACpC,YACE,OAAO,UAAU,eAAe,eAC5B,EAAE,YAAY,CAAC,EAAE,IACjB;AAAA,cACA,cAAc;AAAA,gBACZ,WAAW,OAAO,UAAU,YACxB,OAAO,OAAO,UAAU,SAAS,IACjC;AAAA,gBACJ,YAAY,OAAO,UAAU;AAAA,gBAC7B,aAAa,OAAO,UAAU;AAAA,cAChC;AAAA,YACF;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK,aAAa;AAChB,aAAO;AAAA,QACL,WAAW;AAAA,UACT,WAAW;AAAA,YACT,YAAY;AAAA,cACV,MAAM,cAAc,OAAO,SAAS;AAAA,YACtC;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK,iBAAiB;AACpB,aAAO;AAAA,QACL,eAAe;AAAA,UACb,eAAe,OAAO;AAAA,QACxB;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK,kBAAkB;AACrB,aAAO;AAAA,QACL,gBAAgB;AAAA,UACd,gBAAgB,UAAU,OAAO,cAAc;AAAA,UAC/C,WAAW;AAAA,YACT,kBAAkB,WAAW,OAAO,SAAS;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AACP,YAAM,IAAI,MAAM,6BAA6B,OAAO,IAAI;AAAA,IAC1D;AAAA,EACF;AACF;AAvGgB;AAyGT,MAAM,SAAS,eAAe;","names":[]}
@@ -1,5 +1,5 @@
1
- /* ⋈ 🏃🏻💨 FastNEAR Utils - IIFE/UMD (@fastnear/utils version 0.9.5) */
2
- /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.5 */
1
+ /* ⋈ 🏃🏻💨 FastNEAR Utils - IIFE/UMD (@fastnear/utils version 0.9.7) */
2
+ /* https://www.npmjs.com/package/@fastnear/utils/v/0.9.7 */
3
3
  "use strict";
4
4
  var NearUtils = (() => {
5
5
  var __create = Object.create;
@@ -76,7 +76,7 @@ var NearUtils = (() => {
76
76
  txToJsonStringified: () => txToJsonStringified
77
77
  });
78
78
 
79
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js
79
+ // ../../node_modules/@noble/hashes/esm/_assert.js
80
80
  function isBytes(a) {
81
81
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
82
82
  }
@@ -104,12 +104,19 @@ var NearUtils = (() => {
104
104
  }
105
105
  __name(aoutput, "aoutput");
106
106
 
107
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js
107
+ // ../../node_modules/@noble/hashes/esm/cryptoNode.js
108
108
  var nc = __toESM(__require("node:crypto"), 1);
109
109
  var crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
110
110
 
111
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
112
- var createView = /* @__PURE__ */ __name((arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength), "createView");
111
+ // ../../node_modules/@noble/hashes/esm/utils.js
112
+ function createView(arr) {
113
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
114
+ }
115
+ __name(createView, "createView");
116
+ function rotr(word, shift) {
117
+ return word << 32 - shift | word >>> shift;
118
+ }
119
+ __name(rotr, "rotr");
113
120
  function utf8ToBytes(str) {
114
121
  if (typeof str !== "string")
115
122
  throw new Error("utf8ToBytes expected string, got " + typeof str);
@@ -152,7 +159,7 @@ var NearUtils = (() => {
152
159
  }
153
160
  __name(randomBytes, "randomBytes");
154
161
 
155
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js
162
+ // ../../node_modules/@noble/hashes/esm/_md.js
156
163
  function setBigUint64(view, byteOffset, value, isLE) {
157
164
  if (typeof view.setBigUint64 === "function")
158
165
  return view.setBigUint64(byteOffset, value, isLE);
@@ -166,6 +173,14 @@ var NearUtils = (() => {
166
173
  view.setUint32(byteOffset + l, wl, isLE);
167
174
  }
168
175
  __name(setBigUint64, "setBigUint64");
176
+ function Chi(a, b, c) {
177
+ return a & b ^ ~a & c;
178
+ }
179
+ __name(Chi, "Chi");
180
+ function Maj(a, b, c) {
181
+ return a & b ^ a & c ^ b & c;
182
+ }
183
+ __name(Maj, "Maj");
169
184
  var HashMD = class extends Hash {
170
185
  static {
171
186
  __name(this, "HashMD");
@@ -256,7 +271,7 @@ var NearUtils = (() => {
256
271
  }
257
272
  };
258
273
 
259
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js
274
+ // ../../node_modules/@noble/hashes/esm/_u64.js
260
275
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
261
276
  var _32n = /* @__PURE__ */ BigInt(32);
262
277
  function fromBig(n, le = false) {
@@ -325,7 +340,7 @@ var NearUtils = (() => {
325
340
  };
326
341
  var u64_default = u64;
327
342
 
328
- // ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha512.js
343
+ // ../../node_modules/@noble/hashes/esm/sha512.js
329
344
  var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64_default.split([
330
345
  "0x428a2f98d728ae22",
331
346
  "0x7137449123ef65cd",
@@ -925,6 +940,7 @@ var NearUtils = (() => {
925
940
  let sqrtP;
926
941
  const f = Object.freeze({
927
942
  ORDER,
943
+ isLE,
928
944
  BITS,
929
945
  BYTES,
930
946
  MASK: bitMask(BITS),
@@ -1691,175 +1707,6 @@ var NearUtils = (() => {
1691
1707
  }))();
1692
1708
  var ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
1693
1709
 
1694
- // ../../node_modules/@noble/hashes/esm/_assert.js
1695
- function isBytes3(a) {
1696
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
1697
- }
1698
- __name(isBytes3, "isBytes");
1699
- function abytes3(b, ...lengths) {
1700
- if (!isBytes3(b))
1701
- throw new Error("Uint8Array expected");
1702
- if (lengths.length > 0 && !lengths.includes(b.length))
1703
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
1704
- }
1705
- __name(abytes3, "abytes");
1706
- function aexists2(instance, checkFinished = true) {
1707
- if (instance.destroyed)
1708
- throw new Error("Hash instance has been destroyed");
1709
- if (checkFinished && instance.finished)
1710
- throw new Error("Hash#digest() has already been called");
1711
- }
1712
- __name(aexists2, "aexists");
1713
- function aoutput2(out, instance) {
1714
- abytes3(out);
1715
- const min = instance.outputLen;
1716
- if (out.length < min) {
1717
- throw new Error("digestInto() expects output buffer of length at least " + min);
1718
- }
1719
- }
1720
- __name(aoutput2, "aoutput");
1721
-
1722
- // ../../node_modules/@noble/hashes/esm/utils.js
1723
- var createView2 = /* @__PURE__ */ __name((arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength), "createView");
1724
- var rotr = /* @__PURE__ */ __name((word, shift) => word << 32 - shift | word >>> shift, "rotr");
1725
- function utf8ToBytes2(str) {
1726
- if (typeof str !== "string")
1727
- throw new Error("utf8ToBytes expected string, got " + typeof str);
1728
- return new Uint8Array(new TextEncoder().encode(str));
1729
- }
1730
- __name(utf8ToBytes2, "utf8ToBytes");
1731
- function toBytes2(data) {
1732
- if (typeof data === "string")
1733
- data = utf8ToBytes2(data);
1734
- abytes3(data);
1735
- return data;
1736
- }
1737
- __name(toBytes2, "toBytes");
1738
- var Hash2 = class {
1739
- static {
1740
- __name(this, "Hash");
1741
- }
1742
- // Safe version that clones internal state
1743
- clone() {
1744
- return this._cloneInto();
1745
- }
1746
- };
1747
- function wrapConstructor2(hashCons) {
1748
- const hashC = /* @__PURE__ */ __name((msg) => hashCons().update(toBytes2(msg)).digest(), "hashC");
1749
- const tmp = hashCons();
1750
- hashC.outputLen = tmp.outputLen;
1751
- hashC.blockLen = tmp.blockLen;
1752
- hashC.create = () => hashCons();
1753
- return hashC;
1754
- }
1755
- __name(wrapConstructor2, "wrapConstructor");
1756
-
1757
- // ../../node_modules/@noble/hashes/esm/_md.js
1758
- function setBigUint642(view, byteOffset, value, isLE) {
1759
- if (typeof view.setBigUint64 === "function")
1760
- return view.setBigUint64(byteOffset, value, isLE);
1761
- const _32n2 = BigInt(32);
1762
- const _u32_max = BigInt(4294967295);
1763
- const wh = Number(value >> _32n2 & _u32_max);
1764
- const wl = Number(value & _u32_max);
1765
- const h = isLE ? 4 : 0;
1766
- const l = isLE ? 0 : 4;
1767
- view.setUint32(byteOffset + h, wh, isLE);
1768
- view.setUint32(byteOffset + l, wl, isLE);
1769
- }
1770
- __name(setBigUint642, "setBigUint64");
1771
- var Chi = /* @__PURE__ */ __name((a, b, c) => a & b ^ ~a & c, "Chi");
1772
- var Maj = /* @__PURE__ */ __name((a, b, c) => a & b ^ a & c ^ b & c, "Maj");
1773
- var HashMD2 = class extends Hash2 {
1774
- static {
1775
- __name(this, "HashMD");
1776
- }
1777
- constructor(blockLen, outputLen, padOffset, isLE) {
1778
- super();
1779
- this.blockLen = blockLen;
1780
- this.outputLen = outputLen;
1781
- this.padOffset = padOffset;
1782
- this.isLE = isLE;
1783
- this.finished = false;
1784
- this.length = 0;
1785
- this.pos = 0;
1786
- this.destroyed = false;
1787
- this.buffer = new Uint8Array(blockLen);
1788
- this.view = createView2(this.buffer);
1789
- }
1790
- update(data) {
1791
- aexists2(this);
1792
- const { view, buffer, blockLen } = this;
1793
- data = toBytes2(data);
1794
- const len = data.length;
1795
- for (let pos = 0; pos < len; ) {
1796
- const take = Math.min(blockLen - this.pos, len - pos);
1797
- if (take === blockLen) {
1798
- const dataView = createView2(data);
1799
- for (; blockLen <= len - pos; pos += blockLen)
1800
- this.process(dataView, pos);
1801
- continue;
1802
- }
1803
- buffer.set(data.subarray(pos, pos + take), this.pos);
1804
- this.pos += take;
1805
- pos += take;
1806
- if (this.pos === blockLen) {
1807
- this.process(view, 0);
1808
- this.pos = 0;
1809
- }
1810
- }
1811
- this.length += data.length;
1812
- this.roundClean();
1813
- return this;
1814
- }
1815
- digestInto(out) {
1816
- aexists2(this);
1817
- aoutput2(out, this);
1818
- this.finished = true;
1819
- const { buffer, view, blockLen, isLE } = this;
1820
- let { pos } = this;
1821
- buffer[pos++] = 128;
1822
- this.buffer.subarray(pos).fill(0);
1823
- if (this.padOffset > blockLen - pos) {
1824
- this.process(view, 0);
1825
- pos = 0;
1826
- }
1827
- for (let i = pos; i < blockLen; i++)
1828
- buffer[i] = 0;
1829
- setBigUint642(view, blockLen - 8, BigInt(this.length * 8), isLE);
1830
- this.process(view, 0);
1831
- const oview = createView2(out);
1832
- const len = this.outputLen;
1833
- if (len % 4)
1834
- throw new Error("_sha2: outputLen should be aligned to 32bit");
1835
- const outLen = len / 4;
1836
- const state = this.get();
1837
- if (outLen > state.length)
1838
- throw new Error("_sha2: outputLen bigger than state");
1839
- for (let i = 0; i < outLen; i++)
1840
- oview.setUint32(4 * i, state[i], isLE);
1841
- }
1842
- digest() {
1843
- const { buffer, outputLen } = this;
1844
- this.digestInto(buffer);
1845
- const res = buffer.slice(0, outputLen);
1846
- this.destroy();
1847
- return res;
1848
- }
1849
- _cloneInto(to) {
1850
- to || (to = new this.constructor());
1851
- to.set(...this.get());
1852
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
1853
- to.length = length;
1854
- to.pos = pos;
1855
- to.finished = finished;
1856
- to.destroyed = destroyed;
1857
- if (length % blockLen)
1858
- to.buffer.set(buffer);
1859
- return to;
1860
- }
1861
- };
1862
-
1863
1710
  // ../../node_modules/@noble/hashes/esm/sha256.js
1864
1711
  var SHA256_K = /* @__PURE__ */ new Uint32Array([
1865
1712
  1116352408,
@@ -1938,7 +1785,7 @@ var NearUtils = (() => {
1938
1785
  1541459225
1939
1786
  ]);
1940
1787
  var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
1941
- var SHA256 = class extends HashMD2 {
1788
+ var SHA256 = class extends HashMD {
1942
1789
  static {
1943
1790
  __name(this, "SHA256");
1944
1791
  }
@@ -2011,7 +1858,7 @@ var NearUtils = (() => {
2011
1858
  this.buffer.fill(0);
2012
1859
  }
2013
1860
  };
2014
- var sha256 = /* @__PURE__ */ wrapConstructor2(() => new SHA256());
1861
+ var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
2015
1862
 
2016
1863
  // ../../node_modules/base58-js/base58_chars.mjs
2017
1864
  var base58_chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -3597,21 +3444,17 @@ var NearUtils = (() => {
3597
3444
  case "DeployContract": {
3598
3445
  return {
3599
3446
  deployContract: {
3600
- code: fromBase64(action.codeBase64)
3447
+ code: base64ToBytes(action.codeBase64)
3601
3448
  }
3602
3449
  };
3603
3450
  }
3604
3451
  case "FunctionCall": {
3605
- const argsAsString = JSON.stringify(action.args);
3606
- const argsEncoded = new TextEncoder().encode(argsAsString);
3607
- const defaultGas = BigInt("225000000000000");
3608
- const defaultDeposit = BigInt("0");
3609
3452
  return {
3610
3453
  functionCall: {
3611
3454
  methodName: action.methodName,
3612
- args: argsEncoded,
3613
- gas: BigInt(action.gas ?? defaultGas),
3614
- deposit: BigInt(action.deposit ?? defaultDeposit)
3455
+ args: action.argsBase64 !== null && action.argsBase64 !== void 0 ? base64ToBytes(action.argsBase64) : new TextEncoder().encode(JSON.stringify(action.args)),
3456
+ gas: BigInt(action.gas ?? "300000000000000"),
3457
+ deposit: BigInt(action.deposit ?? "0")
3615
3458
  }
3616
3459
  };
3617
3460
  }
@@ -3720,9 +3563,6 @@ var NearUtils = (() => {
3720
3563
 
3721
3564
  @noble/curves/esm/ed25519.js:
3722
3565
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
3723
-
3724
- @noble/hashes/esm/utils.js:
3725
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
3726
3566
  */
3727
3567
 
3728
3568
  Object.defineProperty(globalThis, 'NearUtils', {