@initia/initia.js 0.0.10 → 0.0.12

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.
@@ -49,7 +49,6 @@ var APIRequester = /** @class */ (function () {
49
49
  this.axios = axios_1.default.create({
50
50
  headers: {
51
51
  Accept: 'application/json',
52
- 'Accept-Encoding': '*',
53
52
  },
54
53
  timeout: 30000,
55
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"APIRequester.js","sourceRoot":"","sources":["../../../src/client/lcd/APIRequester.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6C;AAC7C,0EAAuF;AAS1E,QAAA,OAAO,GAAG,iBAAU,CAAC;AAYlC;IAIE,sBAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,KAAK,GAAG,eAAK,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,iBAAiB,EAAE,GAAG;aACvB;YACD,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;IACL,CAAC;IAEO,sCAAe,GAAvB,UAAwB,QAAgB;QACtC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAElC,GAAG,CAAC,QAAQ,KAAK,GAAG;YAClB,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC3B,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEY,6BAAM,GAAnB,UACE,QAAgB,EAChB,MAAwC;QAAxC,uBAAA,EAAA,WAAwC;;;;gBAElC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAC3C,sBAAO,IAAI,CAAC,KAA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CAAC,CAAC,IAAI,EAAN,CAAM,CAAC,EAAC;;;KACrD;IACH,mBAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,oCAAY"}
@@ -0,0 +1,2 @@
1
+ export declare function bech32ToHex(address: string): string;
2
+ export declare function hexToBech32(address: string): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hexToBech32 = exports.bech32ToHex = void 0;
7
+ var bech32_converting_1 = __importDefault(require("bech32-converting"));
8
+ function bech32ToHex(address) {
9
+ return (0, bech32_converting_1.default)('init').toHex(address);
10
+ }
11
+ exports.bech32ToHex = bech32ToHex;
12
+ function hexToBech32(address) {
13
+ return (0, bech32_converting_1.default)('init').toBech32(address);
14
+ }
15
+ exports.hexToBech32 = hexToBech32;
16
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/util/address.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAwC;AAExC,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAO,IAAA,2BAAO,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAO,IAAA,2BAAO,EAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAFD,kCAEC"}
@@ -1,12 +1,93 @@
1
- import { bcs, BcsWriter, BcsReader, TypeInterface, encodeStr, decodeStr } from '@mysten/bcs';
2
- import { toB64, fromB64, fromHEX, toHEX } from '@mysten/bcs';
3
- export { toB64, fromB64, fromHEX, toHEX };
4
- export { ExtendedBcs as bcs, BcsWriter, BcsReader, TypeInterface, encodeStr, decodeStr };
5
- export declare function serializeString(data: string): string;
6
- export declare function serializeAddress(data: string): string;
7
- export declare function serializeVector(type: string, data: any): string;
8
- export declare function serializeOption(type: string, data: any): string;
9
- export declare function serialize(type: string, data: any): string;
10
- declare class ExtendedBcs extends bcs {
11
- static registerOptionType(name: string, valueType: string): typeof bcs;
1
+ import { StructTypeDefinition } from '@mysten/bcs';
2
+ export declare class BCS {
3
+ private mystenBcs;
4
+ static readonly U8: string;
5
+ static readonly U16: string;
6
+ static readonly U32: string;
7
+ static readonly U64: string;
8
+ static readonly U128: string;
9
+ static readonly U256: string;
10
+ static readonly BOOL: string;
11
+ static readonly VECTOR: string;
12
+ static readonly ADDRESS: string;
13
+ static readonly STRING: string;
14
+ static readonly OPTION: string;
15
+ constructor();
16
+ /**
17
+ * Serialize data to bcs.
18
+ * Return base64 encoded string
19
+ *
20
+ * Preregistered types : `u8`, `u16`, `u32`, `u64`, `u128`, `u256`,
21
+ * `bool`, `vector`, `address`, `string`, `option`
22
+ *
23
+ * @example
24
+ * const bcs = new BCS();
25
+ *
26
+ * const num = bcs.serialize(BCS.U64, 2187462); // numeric
27
+ * const bool = bcs.serialize(BCS.BOOL, true); // bool
28
+ * const vector = bcs.serialize('vector<u64>', [1, 2, 3, 4]); // vector
29
+ * const string = bcs.serialize(BCS.STRING, 'initia'); // string
30
+ * const optionSome = bcs.serialize('option<u64>', 18237); // option some
31
+ * const optionNone = bcs.serialize('option<u64>', null); // option none
32
+ *
33
+ * @param type Name of the type of serialize
34
+ * @param data Data to serialize
35
+ * @param size Serialization buffer size. Default 1024 bytes
36
+ * @return Base64 encoded of serialized data
37
+ */
38
+ serialize(type: string, data: any, size?: number): string;
39
+ /**
40
+ * Deserialize bcs.
41
+ *
42
+ * @example
43
+ *
44
+ * const bcs = new BCS();
45
+ *
46
+ * const num = bcs.serialize(BCS.U64, 2187462);
47
+ * const deNum = bcs.deserialize(BCS.U64, 2187462);
48
+ *
49
+ * @param type Name of the type of deserialize
50
+ * @param data Data to deserialize
51
+ * @param encoding Encoding to use if data is of type String. Default 'base64'
52
+ * @returns
53
+ */
54
+ deserialize<T>(type: string, data: Uint8Array | string, encoding?: string): T;
55
+ /**
56
+ * Safe method to register a custom Move struct. The first argument is a name of the
57
+ * struct which is only used on the FrontEnd and has no affect on serialization results,
58
+ * and the second is a struct description passed as an Object.
59
+ *
60
+ * The description object MUST have the same order on all of the platforms (ie in Move
61
+ * or in Rust).
62
+ *
63
+ * @example
64
+ * // Move struct
65
+ * // struct Data {
66
+ * // num: u64,
67
+ * // str: std::string::String,
68
+ * // vec: vector<bool>,
69
+ * // }
70
+ *
71
+ * const bcs = new BCS();
72
+ *
73
+ * bcs.registerStruct('data', {
74
+ * num: BCS.U64,
75
+ * str: BCS.STRING,
76
+ * vec: 'vector<bool>'
77
+ * });
78
+ *
79
+ * const data = {
80
+ * num: 1234,
81
+ * str: '1234',
82
+ * vec: [true, false, true],
83
+ * };
84
+ *
85
+ * const ser = bcs.serialize('data', data);
86
+ * const de = bcs.deserialize('data', ser);
87
+ *
88
+ * @param name Name of the type to register.
89
+ * @param fields Fields of the struct. Must be in the correct order.
90
+ */
91
+ registerStruct(name: string, fields: StructTypeDefinition): void;
92
+ private registerOptionType;
12
93
  }
package/dist/util/bcs.js CHANGED
@@ -1,103 +1,148 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
2
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.serialize = exports.serializeOption = exports.serializeVector = exports.serializeAddress = exports.serializeString = exports.decodeStr = exports.encodeStr = exports.BcsReader = exports.BcsWriter = exports.bcs = exports.toHEX = exports.fromHEX = exports.fromB64 = exports.toB64 = void 0;
22
- var bech32_converting_1 = __importDefault(require("bech32-converting"));
3
+ exports.BCS = void 0;
23
4
  var bcs_1 = require("@mysten/bcs");
24
- Object.defineProperty(exports, "BcsWriter", { enumerable: true, get: function () { return bcs_1.BcsWriter; } });
25
- Object.defineProperty(exports, "BcsReader", { enumerable: true, get: function () { return bcs_1.BcsReader; } });
26
- Object.defineProperty(exports, "encodeStr", { enumerable: true, get: function () { return bcs_1.encodeStr; } });
27
- Object.defineProperty(exports, "decodeStr", { enumerable: true, get: function () { return bcs_1.decodeStr; } });
28
- var bcs_2 = require("@mysten/bcs");
29
- Object.defineProperty(exports, "toB64", { enumerable: true, get: function () { return bcs_2.toB64; } });
30
- Object.defineProperty(exports, "fromB64", { enumerable: true, get: function () { return bcs_2.fromB64; } });
31
- Object.defineProperty(exports, "fromHEX", { enumerable: true, get: function () { return bcs_2.fromHEX; } });
32
- Object.defineProperty(exports, "toHEX", { enumerable: true, get: function () { return bcs_2.toHEX; } });
33
- function serializeString(data) {
34
- return serialize(ExtendedBcs.STRING, data);
35
- }
36
- exports.serializeString = serializeString;
37
- function serializeAddress(data) {
38
- if (!ExtendedBcs.hasType(ExtendedBcs.ADDRESS)) {
39
- ExtendedBcs.registerAddressType(ExtendedBcs.ADDRESS, 20, 'hex');
40
- }
41
- var converted = (0, bech32_converting_1.default)('init').toHex(data);
42
- return serialize(ExtendedBcs.ADDRESS, converted);
43
- }
44
- exports.serializeAddress = serializeAddress;
45
- function serializeVector(type, data) {
46
- if (!ExtendedBcs.hasType(type)) {
47
- throw Error("Must register type ".concat(type, " first"));
48
- }
49
- var vectorType = "vector<".concat(type, ">");
50
- if (!ExtendedBcs.hasType(vectorType)) {
51
- ExtendedBcs.registerVectorType(vectorType, type);
52
- }
53
- return serialize(vectorType, data);
54
- }
55
- exports.serializeVector = serializeVector;
56
- function serializeOption(type, data) {
57
- if (!ExtendedBcs.hasType(type)) {
58
- throw Error("Must register type ".concat(type, " first"));
59
- }
60
- var optionType = "option<".concat(type, ">");
61
- if (!ExtendedBcs.hasType(optionType)) {
62
- ExtendedBcs.registerOptionType(optionType, type);
63
- }
64
- return serialize(optionType, data);
65
- }
66
- exports.serializeOption = serializeOption;
67
- function serialize(type, data) {
68
- return ExtendedBcs.ser(type, data).toString('base64');
69
- }
70
- exports.serialize = serialize;
71
- var ExtendedBcs = /** @class */ (function (_super) {
72
- __extends(ExtendedBcs, _super);
73
- function ExtendedBcs() {
74
- return _super !== null && _super.apply(this, arguments) || this;
5
+ var BCS = /** @class */ (function () {
6
+ function BCS() {
7
+ this.mystenBcs = new bcs_1.BCS({
8
+ genericSeparators: ['<', '>'],
9
+ vectorType: 'vector',
10
+ addressLength: 20,
11
+ addressEncoding: 'hex',
12
+ });
13
+ this.registerOptionType(BCS.OPTION);
75
14
  }
76
- ExtendedBcs.registerOptionType = function (name, valueType) {
77
- return this.registerType(name, function (writer, data) { return writeOption(writer, data, function (writer, val) {
78
- return bcs_1.bcs.getTypeInterface(valueType)._encodeRaw(writer, val);
79
- }); }, function (reader) { return readOption(reader, function (reader) {
80
- return bcs_1.bcs.getTypeInterface(valueType)._decodeRaw(reader);
81
- }); });
15
+ /**
16
+ * Serialize data to bcs.
17
+ * Return base64 encoded string
18
+ *
19
+ * Preregistered types : `u8`, `u16`, `u32`, `u64`, `u128`, `u256`,
20
+ * `bool`, `vector`, `address`, `string`, `option`
21
+ *
22
+ * @example
23
+ * const bcs = new BCS();
24
+ *
25
+ * const num = bcs.serialize(BCS.U64, 2187462); // numeric
26
+ * const bool = bcs.serialize(BCS.BOOL, true); // bool
27
+ * const vector = bcs.serialize('vector<u64>', [1, 2, 3, 4]); // vector
28
+ * const string = bcs.serialize(BCS.STRING, 'initia'); // string
29
+ * const optionSome = bcs.serialize('option<u64>', 18237); // option some
30
+ * const optionNone = bcs.serialize('option<u64>', null); // option none
31
+ *
32
+ * @param type Name of the type of serialize
33
+ * @param data Data to serialize
34
+ * @param size Serialization buffer size. Default 1024 bytes
35
+ * @return Base64 encoded of serialized data
36
+ */
37
+ BCS.prototype.serialize = function (type, data, size) {
38
+ if (size === void 0) { size = 1024; }
39
+ return this.mystenBcs.ser(type, data, size).toString('base64');
82
40
  };
83
- return ExtendedBcs;
84
- }(bcs_1.bcs));
85
- exports.bcs = ExtendedBcs;
86
- function writeOption(writer, value, cb) {
87
- if (value != null) {
88
- writer.write8(1);
89
- cb(writer, value);
90
- }
91
- else {
92
- writer.write8(0);
93
- }
94
- return writer;
95
- }
96
- function readOption(reader, cb) {
97
- var isSome = reader.read8().toString(10) === '1';
98
- if (!isSome) {
99
- return null;
100
- }
101
- return cb(reader);
102
- }
41
+ /**
42
+ * Deserialize bcs.
43
+ *
44
+ * @example
45
+ *
46
+ * const bcs = new BCS();
47
+ *
48
+ * const num = bcs.serialize(BCS.U64, 2187462);
49
+ * const deNum = bcs.deserialize(BCS.U64, 2187462);
50
+ *
51
+ * @param type Name of the type of deserialize
52
+ * @param data Data to deserialize
53
+ * @param encoding Encoding to use if data is of type String. Default 'base64'
54
+ * @returns
55
+ */
56
+ BCS.prototype.deserialize = function (type, data, encoding) {
57
+ if (encoding === void 0) { encoding = 'base64'; }
58
+ return this.mystenBcs.de(type, data, encoding);
59
+ };
60
+ /**
61
+ * Safe method to register a custom Move struct. The first argument is a name of the
62
+ * struct which is only used on the FrontEnd and has no affect on serialization results,
63
+ * and the second is a struct description passed as an Object.
64
+ *
65
+ * The description object MUST have the same order on all of the platforms (ie in Move
66
+ * or in Rust).
67
+ *
68
+ * @example
69
+ * // Move struct
70
+ * // struct Data {
71
+ * // num: u64,
72
+ * // str: std::string::String,
73
+ * // vec: vector<bool>,
74
+ * // }
75
+ *
76
+ * const bcs = new BCS();
77
+ *
78
+ * bcs.registerStruct('data', {
79
+ * num: BCS.U64,
80
+ * str: BCS.STRING,
81
+ * vec: 'vector<bool>'
82
+ * });
83
+ *
84
+ * const data = {
85
+ * num: 1234,
86
+ * str: '1234',
87
+ * vec: [true, false, true],
88
+ * };
89
+ *
90
+ * const ser = bcs.serialize('data', data);
91
+ * const de = bcs.deserialize('data', ser);
92
+ *
93
+ * @param name Name of the type to register.
94
+ * @param fields Fields of the struct. Must be in the correct order.
95
+ */
96
+ BCS.prototype.registerStruct = function (name, fields) {
97
+ this.mystenBcs.registerStructType(name, fields);
98
+ };
99
+ BCS.prototype.registerOptionType = function (name, elementType) {
100
+ var _this = this;
101
+ var _a = this.mystenBcs.parseTypeName(name), typeName = _a.typeName, typeParams = _a.typeParams;
102
+ if (typeParams.length > 1) {
103
+ throw new Error('Option can have only one type parameter; got ' + name);
104
+ }
105
+ return this.mystenBcs.registerType(typeName, function (writer, data, typeParams) {
106
+ return writer.writeVec(data === null ? [] : [data], function (writer, el) {
107
+ var vectorType = elementType || typeParams[0];
108
+ if (!!vectorType) {
109
+ var _a = _this.mystenBcs.parseTypeName(vectorType), typeName_1 = _a.typeName, typeParams_1 = _a.typeParams;
110
+ return _this.mystenBcs
111
+ .getTypeInterface(elementType || typeName_1)
112
+ ._encodeRaw(writer, el, typeParams_1);
113
+ }
114
+ else {
115
+ throw new Error("Incorrect number of type parameters passed to option '".concat(typeName, "'"));
116
+ }
117
+ });
118
+ }, function (reader, typeParams) {
119
+ var vec = reader.readVec(function (reader) {
120
+ var vectorType = elementType || typeParams[0];
121
+ if (!!vectorType) {
122
+ var _a = _this.mystenBcs.parseTypeName(vectorType), typeName_2 = _a.typeName, typeParams_2 = _a.typeParams;
123
+ return _this.mystenBcs
124
+ .getTypeInterface(elementType || typeName_2)
125
+ ._decodeRaw(reader, typeParams_2);
126
+ }
127
+ else {
128
+ throw new Error("Incorrect number of type parameters passed to option '".concat(typeName, "'"));
129
+ }
130
+ });
131
+ return vec[0] ? vec[0] : null;
132
+ });
133
+ };
134
+ BCS.U8 = 'u8';
135
+ BCS.U16 = 'u16';
136
+ BCS.U32 = 'u32';
137
+ BCS.U64 = 'u64';
138
+ BCS.U128 = 'u128';
139
+ BCS.U256 = 'u256';
140
+ BCS.BOOL = 'bool';
141
+ BCS.VECTOR = 'vector';
142
+ BCS.ADDRESS = 'address';
143
+ BCS.STRING = 'string';
144
+ BCS.OPTION = 'option';
145
+ return BCS;
146
+ }());
147
+ exports.BCS = BCS;
103
148
  //# sourceMappingURL=bcs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bcs.js","sourceRoot":"","sources":["../../src/util/bcs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,wEAA0C;AAC1C,mCAA6F;AAGhE,0FAHf,eAAS,OAGe;AAAE,0FAHf,eAAS,OAGe;AAAiB,0FAHf,eAAS,OAGe;AAAE,0FAHf,eAAS,OAGe;AAFtF,mCAA6D;AACpD,sFADA,WAAK,OACA;AAAE,wFADA,aAAO,OACA;AAAE,wFADA,aAAO,OACA;AAAE,sFADA,WAAK,OACA;AAGvC,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAFD,0CAEC;AAED,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;QAC7C,WAAW,CAAC,mBAAmB,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;KACjE;IACD,IAAM,SAAS,GAAG,IAAA,2BAAS,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAND,4CAMC;AAED,SAAgB,eAAe,CAAC,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AClB,OAAG,GAAW,KAAK,CAAC;IACpB,OAAG,GAAW,KAAK,CAAC;IACpB,OAAG,GAAW,KAAK,CAAC;IACpB,QAAI,GAAW,MAAM,CAAC;IACtB,QAAI,GAAW,MAAM,CAAC;IACtB,QAAI,GAAW,MAAM,CAAC;IACtB,UAAM,GAAW,QAAQ,CAAC;IAC1B,WAAO,GAAW,SAAS,CAAC;IAC5B,UAAM,GAAW,QAAQ,CAAC;IAC1B,UAAM,GAAW,QAAQ,CAAC;IAkJ5C,UAAC;CAAA,AA/JD,IA+JC;AA/JY,kBAAG"}
@@ -1,3 +1,4 @@
1
+ export * from './address';
1
2
  export * from './hash';
2
3
  export * from './contract';
3
4
  export * from './bcs';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./address"), exports);
17
18
  __exportStar(require("./hash"), exports);
18
19
  __exportStar(require("./contract"), exports);
19
20
  __exportStar(require("./bcs"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@initia/initia.js",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "The JavaScript SDK for Initia",
5
5
  "license": "MIT",
6
6
  "author": "InitiaLabs",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@initia/initia.proto": "^0.0.3-alpha1",
86
- "@mysten/bcs": "^0.3.0",
86
+ "@mysten/bcs": "^0.5.0",
87
87
  "axios": "^0.27.2",
88
88
  "bech32": "^2.0.0",
89
89
  "bech32-converting": "^1.0.9",