@fastnear/api 0.4.0 → 0.5.1
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/cjs/index.cjs +40 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +3339 -0
- package/dist/esm/index.d.ts +3339 -0
- package/dist/esm/index.js +9 -60
- package/dist/esm/index.js.map +1 -7
- package/dist/umd/{index.js → browser.global.js} +272 -120
- package/dist/umd/browser.global.js.map +1 -0
- package/package.json +9 -8
- package/dist/cjs/cryptoUtils.js +0 -89
- package/dist/cjs/cryptoUtils.js.map +0 -7
- package/dist/cjs/index.esm.js +0 -1219
- package/dist/cjs/index.esm.js.map +0 -7
- package/dist/cjs/index.js +0 -1274
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/near.js +0 -1219
- package/dist/cjs/near.js.map +0 -7
- package/dist/cjs/transaction.js +0 -360
- package/dist/cjs/transaction.js.map +0 -7
- package/dist/cjs/utils.js +0 -105
- package/dist/cjs/utils.js.map +0 -7
- package/dist/esm/chunk-2SCAGR3F.js +0 -68
- package/dist/esm/chunk-2SCAGR3F.js.map +0 -7
- package/dist/esm/chunk-OR3WITSY.js +0 -842
- package/dist/esm/chunk-OR3WITSY.js.map +0 -7
- package/dist/esm/chunk-S5Q2EM2B.js +0 -48
- package/dist/esm/chunk-S5Q2EM2B.js.map +0 -7
- package/dist/esm/chunk-YKPILPMX.js +0 -301
- package/dist/esm/chunk-YKPILPMX.js.map +0 -7
- package/dist/esm/cryptoUtils.js +0 -21
- package/dist/esm/cryptoUtils.js.map +0 -7
- package/dist/esm/index.esm.js +0 -13
- package/dist/esm/index.esm.js.map +0 -7
- package/dist/esm/near.js +0 -15
- package/dist/esm/near.js.map +0 -7
- package/dist/esm/transaction.js +0 -16
- package/dist/esm/transaction.js.map +0 -7
- package/dist/esm/utils.js +0 -24
- package/dist/esm/utils.js.map +0 -7
- package/dist/umd/index.js.map +0 -7
package/dist/cjs/utils.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - https://github.com/fastnear */
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/utils.ts
|
|
31
|
-
var utils_exports = {};
|
|
32
|
-
__export(utils_exports, {
|
|
33
|
-
canSignWithLAK: () => canSignWithLAK,
|
|
34
|
-
deepCopy: () => deepCopy,
|
|
35
|
-
fromBase58: () => import_base58_js.base58_to_binary,
|
|
36
|
-
fromBase64: () => fromBase64,
|
|
37
|
-
lsGet: () => lsGet,
|
|
38
|
-
lsSet: () => lsSet,
|
|
39
|
-
toBase58: () => import_base58_js.binary_to_base58,
|
|
40
|
-
toBase64: () => toBase64,
|
|
41
|
-
tryParseJson: () => tryParseJson
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(utils_exports);
|
|
44
|
-
var import_base58_js = require("base58-js");
|
|
45
|
-
var import_big = __toESM(require("big.js"), 1);
|
|
46
|
-
var import_js_base64 = require("js-base64");
|
|
47
|
-
var LsPrefix = "__fastnear_";
|
|
48
|
-
function toBase64(data) {
|
|
49
|
-
if (typeof data === "string") {
|
|
50
|
-
return (0, import_js_base64.encode)(data);
|
|
51
|
-
} else {
|
|
52
|
-
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
53
|
-
const str = String.fromCharCode(...bytes);
|
|
54
|
-
return (0, import_js_base64.encode)(str);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function fromBase64(str) {
|
|
58
|
-
const binaryString = (0, import_js_base64.decode)(str);
|
|
59
|
-
const len = binaryString.length;
|
|
60
|
-
const bytes = new Uint8Array(len);
|
|
61
|
-
for (let i = 0; i < len; i++) {
|
|
62
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
63
|
-
}
|
|
64
|
-
return bytes;
|
|
65
|
-
}
|
|
66
|
-
function lsSet(key, value) {
|
|
67
|
-
if (value === null || value === void 0) {
|
|
68
|
-
localStorage.removeItem(LsPrefix + key);
|
|
69
|
-
} else {
|
|
70
|
-
localStorage.setItem(LsPrefix + key, JSON.stringify(value));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function lsGet(key) {
|
|
74
|
-
const value = localStorage.getItem(LsPrefix + key);
|
|
75
|
-
return tryParseJson(value, null);
|
|
76
|
-
}
|
|
77
|
-
function deepCopy(obj) {
|
|
78
|
-
return JSON.parse(JSON.stringify(obj));
|
|
79
|
-
}
|
|
80
|
-
function tryParseJson(...args) {
|
|
81
|
-
try {
|
|
82
|
-
return JSON.parse(args[0]);
|
|
83
|
-
} catch {
|
|
84
|
-
if (args.length > 1) {
|
|
85
|
-
return args[1];
|
|
86
|
-
}
|
|
87
|
-
return args[0];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function canSignWithLAK(actions) {
|
|
91
|
-
return actions.length === 1 && actions[0].type === "FunctionCall" && (0, import_big.default)(actions[0]?.deposit ?? "0").eq(0);
|
|
92
|
-
}
|
|
93
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
-
0 && (module.exports = {
|
|
95
|
-
canSignWithLAK,
|
|
96
|
-
deepCopy,
|
|
97
|
-
fromBase58,
|
|
98
|
-
fromBase64,
|
|
99
|
-
lsGet,
|
|
100
|
-
lsSet,
|
|
101
|
-
toBase58,
|
|
102
|
-
toBase64,
|
|
103
|
-
tryParseJson
|
|
104
|
-
});
|
|
105
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/cjs/utils.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n binary_to_base58 as toBase58,\n base58_to_binary as fromBase58,\n} from \"base58-js\";\nimport Big from \"big.js\";\nimport { encode, decode } from 'js-base64';\n\nexport { toBase58, fromBase58 };\n\nconst LsPrefix = \"__fastnear_\";\n\nexport function toBase64(data) {\n if (typeof data === 'string') {\n return encode(data);\n } else {\n const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);\n const str = String.fromCharCode(...bytes);\n return encode(str);\n }\n}\n\nexport function fromBase64(str) {\n const binaryString = decode(str);\n const len = binaryString.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n}\n\nexport function lsSet(key, value) {\n if (value === null || value === undefined) {\n localStorage.removeItem(LsPrefix + key);\n } else {\n localStorage.setItem(LsPrefix + key, JSON.stringify(value));\n }\n}\n\nexport function lsGet(key) {\n const value = localStorage.getItem(LsPrefix + key);\n return tryParseJson(value, null);\n}\n\nexport function deepCopy(obj) {\n return JSON.parse(JSON.stringify(obj));\n}\n\nexport function tryParseJson(...args) {\n try {\n return JSON.parse(args[0]);\n } catch {\n if (args.length > 1) {\n return args[1];\n }\n return args[0];\n }\n}\n\nexport function canSignWithLAK(actions) {\n return (\n actions.length === 1 &&\n actions[0].type === \"FunctionCall\" &&\n Big(actions[0]?.deposit ?? \"0\").eq(0)\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAAA;AAAA,EAAA;AAAA;AAAA;AAAA,mCAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,uBAGO;AACP,iBAAgB;AAChB,uBAA+B;AAI/B,IAAM,WAAW;AAEV,SAAS,SAAS,MAAM;AAC7B,MAAI,OAAO,SAAS,UAAU;AAC5B,eAAO,yBAAO,IAAI;AAAA,EACpB,OAAO;AACL,UAAM,QAAQ,gBAAgB,aAAa,OAAO,IAAI,WAAW,IAAI;AACrE,UAAM,MAAM,OAAO,aAAa,GAAG,KAAK;AACxC,eAAO,yBAAO,GAAG;AAAA,EACnB;AACF;AAEO,SAAS,WAAW,KAAK;AAC9B,QAAM,mBAAe,yBAAO,GAAG;AAC/B,QAAM,MAAM,aAAa;AACzB,QAAM,QAAQ,IAAI,WAAW,GAAG;AAChC,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,UAAM,CAAC,IAAI,aAAa,WAAW,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAEO,SAAS,MAAM,KAAK,OAAO;AAChC,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,iBAAa,WAAW,WAAW,GAAG;AAAA,EACxC,OAAO;AACL,iBAAa,QAAQ,WAAW,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EAC5D;AACF;AAEO,SAAS,MAAM,KAAK;AACzB,QAAM,QAAQ,aAAa,QAAQ,WAAW,GAAG;AACjD,SAAO,aAAa,OAAO,IAAI;AACjC;AAEO,SAAS,SAAS,KAAK;AAC5B,SAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AACvC;AAEO,SAAS,gBAAgB,MAAM;AACpC,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA,EAC3B,QAAQ;AACN,QAAI,KAAK,SAAS,GAAG;AACnB,aAAO,KAAK,CAAC;AAAA,IACf;AACA,WAAO,KAAK,CAAC;AAAA,EACf;AACF;AAEO,SAAS,eAAe,SAAS;AACtC,SACE,QAAQ,WAAW,KACnB,QAAQ,CAAC,EAAE,SAAS,sBACpB,WAAAC,SAAI,QAAQ,CAAC,GAAG,WAAW,GAAG,EAAE,GAAG,CAAC;AAExC;",
|
|
6
|
-
"names": ["fromBase58", "toBase58", "Big"]
|
|
7
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - https://github.com/fastnear */
|
|
2
|
-
|
|
3
|
-
// src/utils.ts
|
|
4
|
-
import {
|
|
5
|
-
binary_to_base58 as toBase58,
|
|
6
|
-
base58_to_binary as fromBase58
|
|
7
|
-
} from "base58-js";
|
|
8
|
-
import Big from "big.js";
|
|
9
|
-
import { encode, decode } from "js-base64";
|
|
10
|
-
var LsPrefix = "__fastnear_";
|
|
11
|
-
function toBase64(data) {
|
|
12
|
-
if (typeof data === "string") {
|
|
13
|
-
return encode(data);
|
|
14
|
-
} else {
|
|
15
|
-
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
16
|
-
const str = String.fromCharCode(...bytes);
|
|
17
|
-
return encode(str);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function fromBase64(str) {
|
|
21
|
-
const binaryString = decode(str);
|
|
22
|
-
const len = binaryString.length;
|
|
23
|
-
const bytes = new Uint8Array(len);
|
|
24
|
-
for (let i = 0; i < len; i++) {
|
|
25
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
26
|
-
}
|
|
27
|
-
return bytes;
|
|
28
|
-
}
|
|
29
|
-
function lsSet(key, value) {
|
|
30
|
-
if (value === null || value === void 0) {
|
|
31
|
-
localStorage.removeItem(LsPrefix + key);
|
|
32
|
-
} else {
|
|
33
|
-
localStorage.setItem(LsPrefix + key, JSON.stringify(value));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function lsGet(key) {
|
|
37
|
-
const value = localStorage.getItem(LsPrefix + key);
|
|
38
|
-
return tryParseJson(value, null);
|
|
39
|
-
}
|
|
40
|
-
function deepCopy(obj) {
|
|
41
|
-
return JSON.parse(JSON.stringify(obj));
|
|
42
|
-
}
|
|
43
|
-
function tryParseJson(...args) {
|
|
44
|
-
try {
|
|
45
|
-
return JSON.parse(args[0]);
|
|
46
|
-
} catch {
|
|
47
|
-
if (args.length > 1) {
|
|
48
|
-
return args[1];
|
|
49
|
-
}
|
|
50
|
-
return args[0];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function canSignWithLAK(actions) {
|
|
54
|
-
return actions.length === 1 && actions[0].type === "FunctionCall" && Big(actions[0]?.deposit ?? "0").eq(0);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
toBase58,
|
|
59
|
-
fromBase58,
|
|
60
|
-
toBase64,
|
|
61
|
-
fromBase64,
|
|
62
|
-
lsSet,
|
|
63
|
-
lsGet,
|
|
64
|
-
deepCopy,
|
|
65
|
-
tryParseJson,
|
|
66
|
-
canSignWithLAK
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=chunk-2SCAGR3F.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n binary_to_base58 as toBase58,\n base58_to_binary as fromBase58,\n} from \"base58-js\";\nimport Big from \"big.js\";\nimport { encode, decode } from 'js-base64';\n\nexport { toBase58, fromBase58 };\n\nconst LsPrefix = \"__fastnear_\";\n\nexport function toBase64(data) {\n if (typeof data === 'string') {\n return encode(data);\n } else {\n const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);\n const str = String.fromCharCode(...bytes);\n return encode(str);\n }\n}\n\nexport function fromBase64(str) {\n const binaryString = decode(str);\n const len = binaryString.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n}\n\nexport function lsSet(key, value) {\n if (value === null || value === undefined) {\n localStorage.removeItem(LsPrefix + key);\n } else {\n localStorage.setItem(LsPrefix + key, JSON.stringify(value));\n }\n}\n\nexport function lsGet(key) {\n const value = localStorage.getItem(LsPrefix + key);\n return tryParseJson(value, null);\n}\n\nexport function deepCopy(obj) {\n return JSON.parse(JSON.stringify(obj));\n}\n\nexport function tryParseJson(...args) {\n try {\n return JSON.parse(args[0]);\n } catch {\n if (args.length > 1) {\n return args[1];\n }\n return args[0];\n }\n}\n\nexport function canSignWithLAK(actions) {\n return (\n actions.length === 1 &&\n actions[0].type === \"FunctionCall\" &&\n Big(actions[0]?.deposit ?? \"0\").eq(0)\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;AAAA;AAAA,EACE,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,OACf;AACP,OAAO,SAAS;AAChB,SAAS,QAAQ,cAAc;AAI/B,IAAM,WAAW;AAEV,SAAS,SAAS,MAAM;AAC7B,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,OAAO,IAAI;AAAA,EACpB,OAAO;AACL,UAAM,QAAQ,gBAAgB,aAAa,OAAO,IAAI,WAAW,IAAI;AACrE,UAAM,MAAM,OAAO,aAAa,GAAG,KAAK;AACxC,WAAO,OAAO,GAAG;AAAA,EACnB;AACF;AAEO,SAAS,WAAW,KAAK;AAC9B,QAAM,eAAe,OAAO,GAAG;AAC/B,QAAM,MAAM,aAAa;AACzB,QAAM,QAAQ,IAAI,WAAW,GAAG;AAChC,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,UAAM,CAAC,IAAI,aAAa,WAAW,CAAC;AAAA,EACtC;AACA,SAAO;AACT;AAEO,SAAS,MAAM,KAAK,OAAO;AAChC,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,iBAAa,WAAW,WAAW,GAAG;AAAA,EACxC,OAAO;AACL,iBAAa,QAAQ,WAAW,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EAC5D;AACF;AAEO,SAAS,MAAM,KAAK;AACzB,QAAM,QAAQ,aAAa,QAAQ,WAAW,GAAG;AACjD,SAAO,aAAa,OAAO,IAAI;AACjC;AAEO,SAAS,SAAS,KAAK;AAC5B,SAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AACvC;AAEO,SAAS,gBAAgB,MAAM;AACpC,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA,EAC3B,QAAQ;AACN,QAAI,KAAK,SAAS,GAAG;AACnB,aAAO,KAAK,CAAC;AAAA,IACf;AACA,WAAO,KAAK,CAAC;AAAA,EACf;AACF;AAEO,SAAS,eAAe,SAAS;AACtC,SACE,QAAQ,WAAW,KACnB,QAAQ,CAAC,EAAE,SAAS,kBACpB,IAAI,QAAQ,CAAC,GAAG,WAAW,GAAG,EAAE,GAAG,CAAC;AAExC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|