@alephium/web3 0.2.2 → 0.3.0-rc.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/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +4 -4
- package/dist/src/api/api-alephium.js +1 -1
- package/dist/src/api/api-explorer.d.ts +25 -0
- package/dist/src/api/api-explorer.js +29 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.js +2 -1
- package/dist/src/utils/utils.d.ts +1 -1
- package/dist/src/utils/utils.js +10 -3
- package/package.json +3 -3
- package/src/api/api-alephium.ts +4 -4
- package/src/api/api-explorer.ts +44 -0
- package/src/constants.ts +1 -0
- package/src/utils/utils.ts +10 -4
|
@@ -737,11 +737,11 @@ export interface UTXO {
|
|
|
737
737
|
ref: OutputRef;
|
|
738
738
|
/** @format uint256 */
|
|
739
739
|
amount: string;
|
|
740
|
-
tokens
|
|
740
|
+
tokens?: Token[];
|
|
741
741
|
/** @format int64 */
|
|
742
|
-
lockTime
|
|
742
|
+
lockTime?: number;
|
|
743
743
|
/** @format hex-string */
|
|
744
|
-
additionalData
|
|
744
|
+
additionalData?: string;
|
|
745
745
|
}
|
|
746
746
|
export interface UTXOs {
|
|
747
747
|
utxos: UTXO[];
|
|
@@ -908,7 +908,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
908
908
|
}
|
|
909
909
|
/**
|
|
910
910
|
* @title Alephium API
|
|
911
|
-
* @version 1.
|
|
911
|
+
* @version 1.6.0
|
|
912
912
|
* @baseUrl ../
|
|
913
913
|
*/
|
|
914
914
|
export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
|
@@ -91,6 +91,8 @@ export interface Input {
|
|
|
91
91
|
outputRef: OutputRef;
|
|
92
92
|
/** @format hex-string */
|
|
93
93
|
unlockScript?: string;
|
|
94
|
+
/** @format 32-byte-hash */
|
|
95
|
+
txHashRef?: string;
|
|
94
96
|
address?: string;
|
|
95
97
|
/** @format uint256 */
|
|
96
98
|
attoAlphAmount?: string;
|
|
@@ -352,6 +354,18 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
352
354
|
limit?: number;
|
|
353
355
|
reverse?: boolean;
|
|
354
356
|
}, params?: RequestParams) => Promise<Transaction[]>;
|
|
357
|
+
/**
|
|
358
|
+
* @description List transactions for given addresses
|
|
359
|
+
*
|
|
360
|
+
* @tags Addresses
|
|
361
|
+
* @name PostAddressesTransactions
|
|
362
|
+
* @request POST:/addresses/transactions
|
|
363
|
+
*/
|
|
364
|
+
postAddressesTransactions: (query?: {
|
|
365
|
+
page?: number;
|
|
366
|
+
limit?: number;
|
|
367
|
+
reverse?: boolean;
|
|
368
|
+
}, data?: string[], params?: RequestParams) => Promise<Transaction[]>;
|
|
355
369
|
/**
|
|
356
370
|
* @description List transactions of a given address within a time-range
|
|
357
371
|
*
|
|
@@ -418,6 +432,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
418
432
|
* @request GET:/addresses/{address}/tokens/{token_id}/balance
|
|
419
433
|
*/
|
|
420
434
|
getAddressesAddressTokensTokenIdBalance: (address: string, tokenId: string, params?: RequestParams) => Promise<AddressBalance>;
|
|
435
|
+
/**
|
|
436
|
+
* No description
|
|
437
|
+
*
|
|
438
|
+
* @tags Addresses
|
|
439
|
+
* @name GetAddressesAddressExportTransactionsCsv
|
|
440
|
+
* @request GET:/addresses/{address}/export-transactions/csv
|
|
441
|
+
*/
|
|
442
|
+
getAddressesAddressExportTransactionsCsv: (address: string, query: {
|
|
443
|
+
fromTs: number;
|
|
444
|
+
toTs: number;
|
|
445
|
+
}, params?: RequestParams) => Promise<string>;
|
|
421
446
|
};
|
|
422
447
|
addressesActive: {
|
|
423
448
|
/**
|
|
@@ -253,6 +253,22 @@ class Api extends HttpClient {
|
|
|
253
253
|
format: 'json',
|
|
254
254
|
...params
|
|
255
255
|
}).then(utils_1.convertHttpResponse),
|
|
256
|
+
/**
|
|
257
|
+
* @description List transactions for given addresses
|
|
258
|
+
*
|
|
259
|
+
* @tags Addresses
|
|
260
|
+
* @name PostAddressesTransactions
|
|
261
|
+
* @request POST:/addresses/transactions
|
|
262
|
+
*/
|
|
263
|
+
postAddressesTransactions: (query, data, params = {}) => this.request({
|
|
264
|
+
path: `/addresses/transactions`,
|
|
265
|
+
method: 'POST',
|
|
266
|
+
query: query,
|
|
267
|
+
body: data,
|
|
268
|
+
type: ContentType.Json,
|
|
269
|
+
format: 'json',
|
|
270
|
+
...params
|
|
271
|
+
}).then(utils_1.convertHttpResponse),
|
|
256
272
|
/**
|
|
257
273
|
* @description List transactions of a given address within a time-range
|
|
258
274
|
*
|
|
@@ -345,6 +361,19 @@ class Api extends HttpClient {
|
|
|
345
361
|
method: 'GET',
|
|
346
362
|
format: 'json',
|
|
347
363
|
...params
|
|
364
|
+
}).then(utils_1.convertHttpResponse),
|
|
365
|
+
/**
|
|
366
|
+
* No description
|
|
367
|
+
*
|
|
368
|
+
* @tags Addresses
|
|
369
|
+
* @name GetAddressesAddressExportTransactionsCsv
|
|
370
|
+
* @request GET:/addresses/{address}/export-transactions/csv
|
|
371
|
+
*/
|
|
372
|
+
getAddressesAddressExportTransactionsCsv: (address, query, params = {}) => this.request({
|
|
373
|
+
path: `/addresses/${address}/export-transactions/csv`,
|
|
374
|
+
method: 'GET',
|
|
375
|
+
query: query,
|
|
376
|
+
...params
|
|
348
377
|
}).then(utils_1.convertHttpResponse)
|
|
349
378
|
};
|
|
350
379
|
this.addressesActive = {
|
package/dist/src/constants.d.ts
CHANGED
package/dist/src/constants.js
CHANGED
|
@@ -17,6 +17,7 @@ You should have received a copy of the GNU Lesser General Public License
|
|
|
17
17
|
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MIN_UTXO_SET_AMOUNT = exports.TOTAL_NUMBER_OF_GROUPS = void 0;
|
|
20
|
+
exports.ALPH_TOKEN_ID = exports.MIN_UTXO_SET_AMOUNT = exports.TOTAL_NUMBER_OF_GROUPS = void 0;
|
|
21
21
|
exports.TOTAL_NUMBER_OF_GROUPS = 4;
|
|
22
22
|
exports.MIN_UTXO_SET_AMOUNT = BigInt(1000000000000);
|
|
23
|
+
exports.ALPH_TOKEN_ID = ''.padStart(64, '0');
|
|
@@ -13,7 +13,7 @@ export declare function publicKeyFromPrivateKey(privateKey: string): string;
|
|
|
13
13
|
export declare function addressFromPublicKey(publicKey: string): string;
|
|
14
14
|
export declare function addressFromContractId(contractId: string): string;
|
|
15
15
|
export declare function contractIdFromTx(txId: string, outputIndex: number): string;
|
|
16
|
-
export declare function subContractId(parentContractId: string, pathInHex: string): string;
|
|
16
|
+
export declare function subContractId(parentContractId: string, pathInHex: string, group: number): string;
|
|
17
17
|
export declare function stringToHex(str: string): string;
|
|
18
18
|
export declare function hexToString(str: string): string;
|
|
19
19
|
export declare function timeout(ms: number): Promise<void>;
|
package/dist/src/utils/utils.js
CHANGED
|
@@ -64,7 +64,7 @@ function xorByte(intValue) {
|
|
|
64
64
|
}
|
|
65
65
|
exports.xorByte = xorByte;
|
|
66
66
|
function isHexString(input) {
|
|
67
|
-
return input.length % 2 === 0 &&
|
|
67
|
+
return input.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(input);
|
|
68
68
|
}
|
|
69
69
|
exports.isHexString = isHexString;
|
|
70
70
|
var AddressType;
|
|
@@ -177,9 +177,16 @@ function contractIdFromTx(txId, outputIndex) {
|
|
|
177
177
|
return binToHex(hash);
|
|
178
178
|
}
|
|
179
179
|
exports.contractIdFromTx = contractIdFromTx;
|
|
180
|
-
function subContractId(parentContractId, pathInHex) {
|
|
180
|
+
function subContractId(parentContractId, pathInHex, group) {
|
|
181
|
+
if (group < 0 || group >= constants_1.TOTAL_NUMBER_OF_GROUPS) {
|
|
182
|
+
throw new Error(`Invalid group ${group}`);
|
|
183
|
+
}
|
|
181
184
|
const data = buffer_1.Buffer.concat([hexToBinUnsafe(parentContractId), hexToBinUnsafe(pathInHex)]);
|
|
182
|
-
|
|
185
|
+
const bytes = buffer_1.Buffer.concat([
|
|
186
|
+
blakejs_1.default.blake2b(blakejs_1.default.blake2b(data, undefined, 32), undefined, 32).slice(0, -1),
|
|
187
|
+
buffer_1.Buffer.from([group])
|
|
188
|
+
]);
|
|
189
|
+
return binToHex(bytes);
|
|
183
190
|
}
|
|
184
191
|
exports.subContractId = subContractId;
|
|
185
192
|
function stringToHex(str) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-rc.0",
|
|
4
4
|
"description": "A JS/TS library to interact with the Alephium platform",
|
|
5
5
|
"license": "GPL",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"author": "Alephium dev <dev@alephium.org>",
|
|
29
29
|
"config": {
|
|
30
|
-
"alephium_version": "1.
|
|
31
|
-
"explorer_backend_version": "1.
|
|
30
|
+
"alephium_version": "1.6.0-rc0",
|
|
31
|
+
"explorer_backend_version": "1.11.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rm -rf dist/* && npx tsc --build . && webpack",
|
package/src/api/api-alephium.ts
CHANGED
|
@@ -979,13 +979,13 @@ export interface UTXO {
|
|
|
979
979
|
|
|
980
980
|
/** @format uint256 */
|
|
981
981
|
amount: string
|
|
982
|
-
tokens
|
|
982
|
+
tokens?: Token[]
|
|
983
983
|
|
|
984
984
|
/** @format int64 */
|
|
985
|
-
lockTime
|
|
985
|
+
lockTime?: number
|
|
986
986
|
|
|
987
987
|
/** @format hex-string */
|
|
988
|
-
additionalData
|
|
988
|
+
additionalData?: string
|
|
989
989
|
}
|
|
990
990
|
|
|
991
991
|
export interface UTXOs {
|
|
@@ -1332,7 +1332,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
1332
1332
|
|
|
1333
1333
|
/**
|
|
1334
1334
|
* @title Alephium API
|
|
1335
|
-
* @version 1.
|
|
1335
|
+
* @version 1.6.0
|
|
1336
1336
|
* @baseUrl ../
|
|
1337
1337
|
*/
|
|
1338
1338
|
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
package/src/api/api-explorer.ts
CHANGED
|
@@ -133,6 +133,9 @@ export interface Input {
|
|
|
133
133
|
|
|
134
134
|
/** @format hex-string */
|
|
135
135
|
unlockScript?: string
|
|
136
|
+
|
|
137
|
+
/** @format 32-byte-hash */
|
|
138
|
+
txHashRef?: string
|
|
136
139
|
address?: string
|
|
137
140
|
|
|
138
141
|
/** @format uint256 */
|
|
@@ -637,6 +640,28 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
637
640
|
...params
|
|
638
641
|
}).then(convertHttpResponse),
|
|
639
642
|
|
|
643
|
+
/**
|
|
644
|
+
* @description List transactions for given addresses
|
|
645
|
+
*
|
|
646
|
+
* @tags Addresses
|
|
647
|
+
* @name PostAddressesTransactions
|
|
648
|
+
* @request POST:/addresses/transactions
|
|
649
|
+
*/
|
|
650
|
+
postAddressesTransactions: (
|
|
651
|
+
query?: { page?: number; limit?: number; reverse?: boolean },
|
|
652
|
+
data?: string[],
|
|
653
|
+
params: RequestParams = {}
|
|
654
|
+
) =>
|
|
655
|
+
this.request<Transaction[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
656
|
+
path: `/addresses/transactions`,
|
|
657
|
+
method: 'POST',
|
|
658
|
+
query: query,
|
|
659
|
+
body: data,
|
|
660
|
+
type: ContentType.Json,
|
|
661
|
+
format: 'json',
|
|
662
|
+
...params
|
|
663
|
+
}).then(convertHttpResponse),
|
|
664
|
+
|
|
640
665
|
/**
|
|
641
666
|
* @description List transactions of a given address within a time-range
|
|
642
667
|
*
|
|
@@ -751,6 +776,25 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
751
776
|
method: 'GET',
|
|
752
777
|
format: 'json',
|
|
753
778
|
...params
|
|
779
|
+
}).then(convertHttpResponse),
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* No description
|
|
783
|
+
*
|
|
784
|
+
* @tags Addresses
|
|
785
|
+
* @name GetAddressesAddressExportTransactionsCsv
|
|
786
|
+
* @request GET:/addresses/{address}/export-transactions/csv
|
|
787
|
+
*/
|
|
788
|
+
getAddressesAddressExportTransactionsCsv: (
|
|
789
|
+
address: string,
|
|
790
|
+
query: { fromTs: number; toTs: number },
|
|
791
|
+
params: RequestParams = {}
|
|
792
|
+
) =>
|
|
793
|
+
this.request<string, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
|
|
794
|
+
path: `/addresses/${address}/export-transactions/csv`,
|
|
795
|
+
method: 'GET',
|
|
796
|
+
query: query,
|
|
797
|
+
...params
|
|
754
798
|
}).then(convertHttpResponse)
|
|
755
799
|
}
|
|
756
800
|
addressesActive = {
|
package/src/constants.ts
CHANGED
package/src/utils/utils.ts
CHANGED
|
@@ -63,7 +63,7 @@ export function xorByte(intValue: number): number {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function isHexString(input: string): boolean {
|
|
66
|
-
return input.length % 2 === 0 &&
|
|
66
|
+
return input.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(input)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
enum AddressType {
|
|
@@ -181,10 +181,16 @@ export function contractIdFromTx(txId: string, outputIndex: number): string {
|
|
|
181
181
|
return binToHex(hash)
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
export function subContractId(parentContractId: string, pathInHex: string): string {
|
|
184
|
+
export function subContractId(parentContractId: string, pathInHex: string, group: number): string {
|
|
185
|
+
if (group < 0 || group >= TOTAL_NUMBER_OF_GROUPS) {
|
|
186
|
+
throw new Error(`Invalid group ${group}`)
|
|
187
|
+
}
|
|
185
188
|
const data = Buffer.concat([hexToBinUnsafe(parentContractId), hexToBinUnsafe(pathInHex)])
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
const bytes = Buffer.concat([
|
|
190
|
+
blake.blake2b(blake.blake2b(data, undefined, 32), undefined, 32).slice(0, -1),
|
|
191
|
+
Buffer.from([group])
|
|
192
|
+
])
|
|
193
|
+
return binToHex(bytes)
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
export function stringToHex(str: string): string {
|