koilib 2.6.0 → 2.8.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/README.md +5 -5
- package/dist/koinos.js +178 -688
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +9 -11
- package/lib/Contract.js +12 -12
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +24 -17
- package/lib/Provider.js +83 -81
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +6 -2
- package/lib/Serializer.js +10 -4
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +24 -10
- package/lib/Signer.js +71 -24
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +200 -0
- package/lib/browser/Contract.js +298 -0
- package/lib/browser/Contract.js.map +1 -0
- package/lib/browser/Provider.d.ts +160 -0
- package/lib/browser/Provider.js +246 -0
- package/lib/browser/Provider.js.map +1 -0
- package/lib/browser/Serializer.d.ts +85 -0
- package/lib/browser/Serializer.js +175 -0
- package/lib/browser/Serializer.js.map +1 -0
- package/lib/browser/Signer.d.ts +310 -0
- package/lib/browser/Signer.js +468 -0
- package/lib/browser/Signer.js.map +1 -0
- package/lib/browser/index.d.ts +7 -0
- package/lib/browser/index.js +34 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/index2.d.ts +2 -0
- package/lib/browser/index2.js +33 -0
- package/lib/browser/index2.js.map +1 -0
- package/lib/browser/interface.d.ts +279 -0
- package/lib/browser/interface.js +3 -0
- package/lib/browser/interface.js.map +1 -0
- package/lib/browser/jsonDescriptors/krc20-proto.json +183 -0
- package/lib/browser/jsonDescriptors/protocol-proto.json +246 -0
- package/lib/browser/utils.d.ts +326 -0
- package/lib/browser/utils.js +252 -0
- package/lib/browser/utils.js.map +1 -0
- package/lib/interface.d.ts +22 -21
- package/package.json +9 -6
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ProtocolTypes = exports.Krc20Abi = exports.parseUnits = exports.formatUnits = exports.bitcoinAddress = exports.bitcoinDecode = exports.bitcoinEncode = exports.decodeBase64 = exports.encodeBase64 = exports.decodeBase58 = exports.encodeBase58 = exports.toHexString = exports.toUint8Array = void 0;
|
|
26
|
+
const multibase = __importStar(require("multibase"));
|
|
27
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
28
|
+
const ripemd160_1 = require("@noble/hashes/ripemd160");
|
|
29
|
+
const krc20_proto_json_1 = __importDefault(require("./jsonDescriptors/krc20-proto.json"));
|
|
30
|
+
const protocol_proto_json_1 = __importDefault(require("./jsonDescriptors/protocol-proto.json"));
|
|
31
|
+
/**
|
|
32
|
+
* Converts an hex string to Uint8Array
|
|
33
|
+
*/
|
|
34
|
+
function toUint8Array(hex) {
|
|
35
|
+
const pairs = hex.match(/[\dA-F]{2}/gi);
|
|
36
|
+
if (!pairs)
|
|
37
|
+
throw new Error("Invalid hex");
|
|
38
|
+
return new Uint8Array(pairs.map((s) => parseInt(s, 16)) // convert to integers
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
exports.toUint8Array = toUint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* Converts Uint8Array to hex string
|
|
44
|
+
*/
|
|
45
|
+
function toHexString(buffer) {
|
|
46
|
+
return Array.from(buffer)
|
|
47
|
+
.map((n) => `0${Number(n).toString(16)}`.slice(-2))
|
|
48
|
+
.join("");
|
|
49
|
+
}
|
|
50
|
+
exports.toHexString = toHexString;
|
|
51
|
+
/**
|
|
52
|
+
* Encodes an Uint8Array in base58
|
|
53
|
+
*/
|
|
54
|
+
function encodeBase58(buffer) {
|
|
55
|
+
return new TextDecoder().decode(multibase.encode("z", buffer)).slice(1);
|
|
56
|
+
}
|
|
57
|
+
exports.encodeBase58 = encodeBase58;
|
|
58
|
+
/**
|
|
59
|
+
* Decodes a buffer formatted in base58
|
|
60
|
+
*/
|
|
61
|
+
function decodeBase58(bs58) {
|
|
62
|
+
return multibase.decode(`z${bs58}`);
|
|
63
|
+
}
|
|
64
|
+
exports.decodeBase58 = decodeBase58;
|
|
65
|
+
/**
|
|
66
|
+
* Encodes an Uint8Array in base64
|
|
67
|
+
*/
|
|
68
|
+
function encodeBase64(buffer) {
|
|
69
|
+
return new TextDecoder().decode(multibase.encode("U", buffer)).slice(1);
|
|
70
|
+
}
|
|
71
|
+
exports.encodeBase64 = encodeBase64;
|
|
72
|
+
/**
|
|
73
|
+
* Decodes a buffer formatted in base64
|
|
74
|
+
*/
|
|
75
|
+
function decodeBase64(bs64) {
|
|
76
|
+
return multibase.decode(`U${bs64}`);
|
|
77
|
+
}
|
|
78
|
+
exports.decodeBase64 = decodeBase64;
|
|
79
|
+
/**
|
|
80
|
+
* Encodes a public or private key in base58 using
|
|
81
|
+
* the bitcoin format (see [Bitcoin Base58Check encoding](https://en.bitcoin.it/wiki/Base58Check_encoding)
|
|
82
|
+
* and [Bitcoin WIF](https://en.bitcoin.it/wiki/Wallet_import_format)).
|
|
83
|
+
*
|
|
84
|
+
* For private keys this encode is also known as
|
|
85
|
+
* wallet import format (WIF).
|
|
86
|
+
*/
|
|
87
|
+
function bitcoinEncode(buffer, type, compressed = false) {
|
|
88
|
+
let bufferCheck;
|
|
89
|
+
let prefixBuffer;
|
|
90
|
+
let offsetChecksum;
|
|
91
|
+
if (type === "public") {
|
|
92
|
+
bufferCheck = new Uint8Array(25);
|
|
93
|
+
prefixBuffer = new Uint8Array(21);
|
|
94
|
+
bufferCheck[0] = 0;
|
|
95
|
+
prefixBuffer[0] = 0;
|
|
96
|
+
offsetChecksum = 21;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
if (compressed) {
|
|
100
|
+
bufferCheck = new Uint8Array(38);
|
|
101
|
+
prefixBuffer = new Uint8Array(34);
|
|
102
|
+
offsetChecksum = 34;
|
|
103
|
+
bufferCheck[33] = 1;
|
|
104
|
+
prefixBuffer[33] = 1;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
bufferCheck = new Uint8Array(37);
|
|
108
|
+
prefixBuffer = new Uint8Array(33);
|
|
109
|
+
offsetChecksum = 33;
|
|
110
|
+
}
|
|
111
|
+
bufferCheck[0] = 128;
|
|
112
|
+
prefixBuffer[0] = 128;
|
|
113
|
+
}
|
|
114
|
+
prefixBuffer.set(buffer, 1);
|
|
115
|
+
const firstHash = (0, sha256_1.sha256)(prefixBuffer);
|
|
116
|
+
const doubleHash = (0, sha256_1.sha256)(firstHash);
|
|
117
|
+
const checksum = new Uint8Array(4);
|
|
118
|
+
checksum.set(doubleHash.slice(0, 4));
|
|
119
|
+
bufferCheck.set(buffer, 1);
|
|
120
|
+
bufferCheck.set(checksum, offsetChecksum);
|
|
121
|
+
return encodeBase58(bufferCheck);
|
|
122
|
+
}
|
|
123
|
+
exports.bitcoinEncode = bitcoinEncode;
|
|
124
|
+
/**
|
|
125
|
+
* Decodes a public or private key formatted in base58 using
|
|
126
|
+
* the bitcoin format (see [Bitcoin Base58Check encoding](https://en.bitcoin.it/wiki/Base58Check_encoding)
|
|
127
|
+
* and [Bitcoin WIF](https://en.bitcoin.it/wiki/Wallet_import_format)).
|
|
128
|
+
*
|
|
129
|
+
* For private keys this encode is also known as
|
|
130
|
+
* wallet import format (WIF).
|
|
131
|
+
*/
|
|
132
|
+
function bitcoinDecode(value) {
|
|
133
|
+
const buffer = decodeBase58(value);
|
|
134
|
+
const privateKey = new Uint8Array(32);
|
|
135
|
+
const checksum = new Uint8Array(4);
|
|
136
|
+
// const prefix = buffer[0];
|
|
137
|
+
privateKey.set(buffer.slice(1, 33));
|
|
138
|
+
if (value[0] !== "5") {
|
|
139
|
+
// compressed
|
|
140
|
+
checksum.set(buffer.slice(34, 38));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
checksum.set(buffer.slice(33, 37));
|
|
144
|
+
}
|
|
145
|
+
// TODO: verify prefix and checksum
|
|
146
|
+
return privateKey;
|
|
147
|
+
}
|
|
148
|
+
exports.bitcoinDecode = bitcoinDecode;
|
|
149
|
+
/**
|
|
150
|
+
* Computes a bitcoin address, which is the format used in Koinos
|
|
151
|
+
*
|
|
152
|
+
* address = bitcoinEncode( ripemd160 ( sha256 ( publicKey ) ) )
|
|
153
|
+
*/
|
|
154
|
+
function bitcoinAddress(publicKey) {
|
|
155
|
+
const hash = (0, sha256_1.sha256)(publicKey);
|
|
156
|
+
const hash160 = (0, ripemd160_1.ripemd160)(hash);
|
|
157
|
+
return bitcoinEncode(hash160, "public");
|
|
158
|
+
}
|
|
159
|
+
exports.bitcoinAddress = bitcoinAddress;
|
|
160
|
+
/**
|
|
161
|
+
* Function to format a number in a decimal point number
|
|
162
|
+
* @example
|
|
163
|
+
* ```js
|
|
164
|
+
* const amount = formatUnits("123456", 8);
|
|
165
|
+
* console.log(amount);
|
|
166
|
+
* // '0.00123456'
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
function formatUnits(value, decimals) {
|
|
170
|
+
let v = typeof value === "string" ? value : BigInt(value).toString();
|
|
171
|
+
const sign = v[0] === "-" ? "-" : "";
|
|
172
|
+
v = v.replace("-", "").padStart(decimals + 1, "0");
|
|
173
|
+
const integerPart = v
|
|
174
|
+
.substring(0, v.length - decimals)
|
|
175
|
+
.replace(/^0+(?=\d)/, "");
|
|
176
|
+
const decimalPart = v.substring(v.length - decimals);
|
|
177
|
+
return `${sign}${integerPart}.${decimalPart}`.replace(/(\.0+)?(0+)$/, "");
|
|
178
|
+
}
|
|
179
|
+
exports.formatUnits = formatUnits;
|
|
180
|
+
/**
|
|
181
|
+
* Function to format a decimal point number in an integer
|
|
182
|
+
* @example
|
|
183
|
+
* ```js
|
|
184
|
+
* const amount = parseUnits("0.00123456", 8);
|
|
185
|
+
* console.log(amount);
|
|
186
|
+
* // '123456'
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
function parseUnits(value, decimals) {
|
|
190
|
+
const sign = value[0] === "-" ? "-" : "";
|
|
191
|
+
// eslint-disable-next-line prefer-const
|
|
192
|
+
let [integerPart, decimalPart] = value
|
|
193
|
+
.replace("-", "")
|
|
194
|
+
.replace(",", ".")
|
|
195
|
+
.split(".");
|
|
196
|
+
if (!decimalPart)
|
|
197
|
+
decimalPart = "";
|
|
198
|
+
decimalPart = decimalPart.padEnd(decimals, "0");
|
|
199
|
+
return `${sign}${`${integerPart}${decimalPart}`.replace(/^0+(?=\d)/, "")}`;
|
|
200
|
+
}
|
|
201
|
+
exports.parseUnits = parseUnits;
|
|
202
|
+
/**
|
|
203
|
+
* ABI for tokens
|
|
204
|
+
*/
|
|
205
|
+
exports.Krc20Abi = {
|
|
206
|
+
methods: {
|
|
207
|
+
name: {
|
|
208
|
+
entryPoint: 0x76ea4297,
|
|
209
|
+
input: "name_arguments",
|
|
210
|
+
output: "name_result",
|
|
211
|
+
readOnly: true,
|
|
212
|
+
},
|
|
213
|
+
symbol: {
|
|
214
|
+
entryPoint: 0x7e794b24,
|
|
215
|
+
input: "symbol_arguments",
|
|
216
|
+
output: "symbol_result",
|
|
217
|
+
readOnly: true,
|
|
218
|
+
},
|
|
219
|
+
decimals: {
|
|
220
|
+
entryPoint: 0x59dc15ce,
|
|
221
|
+
input: "decimals_arguments",
|
|
222
|
+
output: "decimals_result",
|
|
223
|
+
readOnly: true,
|
|
224
|
+
},
|
|
225
|
+
totalSupply: {
|
|
226
|
+
entryPoint: 0xcf2e8212,
|
|
227
|
+
input: "total_supply_arguments",
|
|
228
|
+
output: "total_supply_result",
|
|
229
|
+
readOnly: true,
|
|
230
|
+
},
|
|
231
|
+
balanceOf: {
|
|
232
|
+
entryPoint: 0x15619248,
|
|
233
|
+
input: "balance_of_arguments",
|
|
234
|
+
output: "balance_of_result",
|
|
235
|
+
readOnly: true,
|
|
236
|
+
defaultOutput: { value: "0" },
|
|
237
|
+
},
|
|
238
|
+
transfer: {
|
|
239
|
+
entryPoint: 0x62efa292,
|
|
240
|
+
input: "transfer_arguments",
|
|
241
|
+
output: "transfer_result",
|
|
242
|
+
},
|
|
243
|
+
mint: {
|
|
244
|
+
entryPoint: 0xc2f82bdc,
|
|
245
|
+
input: "mint_arguments",
|
|
246
|
+
output: "mint_result",
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
types: krc20_proto_json_1.default,
|
|
250
|
+
};
|
|
251
|
+
exports.ProtocolTypes = protocol_proto_json_1.default;
|
|
252
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,iDAA8C;AAC9C,uDAAoD;AACpD,0FAAgE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BAAc;CACtB,CAAC;AAEW,QAAA,aAAa,GAAG,6BAAY,CAAC"}
|
package/lib/interface.d.ts
CHANGED
|
@@ -132,27 +132,25 @@ export interface RecoverPublicKeyOptions {
|
|
|
132
132
|
*/
|
|
133
133
|
transformSignature?: (signatureData: string) => Promise<string>;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
wait: (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
155
|
-
}
|
|
135
|
+
/**
|
|
136
|
+
* Function to wait for a transaction to be mined.
|
|
137
|
+
* This function comes as a response after sending a transaction.
|
|
138
|
+
* See [[Provider.sendTransaction]]
|
|
139
|
+
*
|
|
140
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
141
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
142
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
143
|
+
* microservice to search the transaction by its id. If non of them is
|
|
144
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
145
|
+
* requires the transaction store, which is an optional microservice).
|
|
146
|
+
*
|
|
147
|
+
* When _byBlock_ is used it returns the block number.
|
|
148
|
+
*
|
|
149
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
150
|
+
*
|
|
151
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
152
|
+
*/
|
|
153
|
+
export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
156
154
|
export interface UploadContractOperation {
|
|
157
155
|
contract_id?: Uint8Array;
|
|
158
156
|
bytecode?: Uint8Array;
|
|
@@ -261,6 +259,9 @@ export interface TransactionJson {
|
|
|
261
259
|
*/
|
|
262
260
|
signature_data?: string;
|
|
263
261
|
}
|
|
262
|
+
export interface TransactionJsonWait extends TransactionJson {
|
|
263
|
+
wait: WaitFunction;
|
|
264
|
+
}
|
|
264
265
|
export interface BlockHeaderJson {
|
|
265
266
|
previous?: string;
|
|
266
267
|
height?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koilib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "JS Koinos Library",
|
|
5
5
|
"author": "Julian Gonzalez",
|
|
6
6
|
"repository": {
|
|
@@ -16,20 +16,23 @@
|
|
|
16
16
|
],
|
|
17
17
|
"main": "./lib/index.js",
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
19
|
-
"browser": "./lib/index.js",
|
|
19
|
+
"browser": "./lib/browser/index.js",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"audit": "audit-ci",
|
|
22
|
-
"build": "
|
|
22
|
+
"build": "yarn build:node && yarn build:browser",
|
|
23
|
+
"build:node": "node helperNodeBrowser.js --node && rimraf lib && tsc -p tsconfig.node.json",
|
|
24
|
+
"build:browser": "rimraf lib/browser && node helperNodeBrowser.js --browser && tsc -p tsconfig.browser.json && node helperNodeBrowser.js --node",
|
|
23
25
|
"bundle": "yarn bundle:no-min && yarn bundle:min",
|
|
24
|
-
"bundle:min": "webpack --mode=production --config webpack.prod.config.js",
|
|
25
|
-
"bundle:no-min": "webpack --mode=production --config webpack.dev.config.js",
|
|
26
|
+
"bundle:min": "node helperNodeBrowser.js --browser && webpack --mode=production --config webpack.prod.config.js && node helperNodeBrowser.js --node",
|
|
27
|
+
"bundle:no-min": "node helperNodeBrowser.js --browser && webpack --mode=production --config webpack.dev.config.js && node helperNodeBrowser.js --browser",
|
|
26
28
|
"docs": "typedoc src/index.ts --includeVersion",
|
|
27
29
|
"clean": "rimraf dist coverage",
|
|
30
|
+
"fix:provider": "node helperNodeBrowser.js --node",
|
|
28
31
|
"lint": "yarn lint:prettier && yarn lint:eslint && yarn lint:tsc",
|
|
29
32
|
"lint:prettier": "prettier . --check",
|
|
30
33
|
"lint:eslint": "eslint . --ext .js,.ts",
|
|
31
34
|
"lint:tsc": "tsc --noEmit --incremental false",
|
|
32
|
-
"prerelease": "yarn
|
|
35
|
+
"prerelease": "yarn bundle && yarn docs && yarn build",
|
|
33
36
|
"proto": "node generateJsonKoinosProto.js",
|
|
34
37
|
"test": "jest",
|
|
35
38
|
"test:unit": "jest wallet.spec.ts",
|