@gnolang/tm2-js-client 2.0.2 → 2.0.4
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/index.cjs +10 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +4 -1
- package/dist/proto/google/protobuf/any.cjs +0 -1
- package/dist/proto/google/protobuf/any.cjs.map +1 -1
- package/dist/proto/google/protobuf/any.d.cts +1 -0
- package/dist/proto/google/protobuf/any.d.cts.map +1 -1
- package/dist/proto/google/protobuf/any.d.mts +1 -0
- package/dist/proto/google/protobuf/any.d.mts.map +1 -1
- package/dist/proto/google/protobuf/any.mjs +0 -1
- package/dist/proto/google/protobuf/any.mjs.map +1 -1
- package/dist/proto/index.cjs +2 -0
- package/dist/proto/index.d.cts +2 -0
- package/dist/proto/index.d.mts +2 -0
- package/dist/proto/index.mjs +2 -0
- package/dist/proto/tm2/abci.cjs +1 -1
- package/dist/proto/tm2/abci.cjs.map +1 -1
- package/dist/proto/tm2/abci.d.cts +2 -1
- package/dist/proto/tm2/abci.d.cts.map +1 -1
- package/dist/proto/tm2/abci.d.mts +2 -1
- package/dist/proto/tm2/abci.d.mts.map +1 -1
- package/dist/proto/tm2/abci.mjs +1 -2
- package/dist/proto/tm2/abci.mjs.map +1 -1
- package/dist/proto/tm2/multisig.cjs +199 -0
- package/dist/proto/tm2/multisig.cjs.map +1 -0
- package/dist/proto/tm2/multisig.d.cts +14 -1
- package/dist/proto/tm2/multisig.d.cts.map +1 -1
- package/dist/proto/tm2/multisig.d.mts +14 -1
- package/dist/proto/tm2/multisig.d.mts.map +1 -1
- package/dist/proto/tm2/multisig.mjs +196 -0
- package/dist/proto/tm2/multisig.mjs.map +1 -0
- package/dist/proto/tm2/tx.cjs.map +1 -1
- package/dist/proto/tm2/tx.mjs.map +1 -1
- package/dist/provider/errors/index.cjs +1 -0
- package/dist/provider/errors/index.d.cts +1 -0
- package/dist/provider/errors/index.d.mts +1 -0
- package/dist/provider/errors/index.mjs +2 -0
- package/dist/provider/index.cjs +2 -0
- package/dist/provider/index.mjs +2 -0
- package/dist/provider/provider.cjs +37 -18
- package/dist/provider/provider.cjs.map +1 -1
- package/dist/provider/provider.d.cts.map +1 -1
- package/dist/provider/provider.d.mts.map +1 -1
- package/dist/provider/provider.mjs +1 -0
- package/dist/provider/provider.mjs.map +1 -1
- package/dist/provider/types/common.cjs +0 -0
- package/dist/provider/types/common.mjs +1 -0
- package/dist/provider/types/index.cjs +3 -0
- package/dist/provider/types/index.d.cts +3 -0
- package/dist/provider/types/index.d.mts +3 -0
- package/dist/provider/types/index.mjs +4 -0
- package/dist/provider/types/jsonrpc.cjs +0 -0
- package/dist/provider/types/jsonrpc.mjs +1 -0
- package/dist/provider/utility/errors.utility.cjs +1 -0
- package/dist/provider/utility/errors.utility.cjs.map +1 -1
- package/dist/provider/utility/errors.utility.mjs +1 -0
- package/dist/provider/utility/errors.utility.mjs.map +1 -1
- package/dist/provider/utility/provider.utility.cjs +7 -5
- package/dist/provider/utility/provider.utility.cjs.map +1 -1
- package/dist/provider/utility/provider.utility.d.cts +1 -1
- package/dist/provider/utility/provider.utility.d.cts.map +1 -1
- package/dist/provider/utility/provider.utility.d.mts +1 -1
- package/dist/provider/utility/provider.utility.d.mts.map +1 -1
- package/dist/provider/utility/provider.utility.mjs +2 -1
- package/dist/provider/utility/provider.utility.mjs.map +1 -1
- package/dist/provider/utility/requests.utility.d.cts.map +1 -1
- package/dist/provider/utility/requests.utility.d.mts.map +1 -1
- package/dist/services/index.cjs +1 -0
- package/dist/services/index.mjs +1 -0
- package/dist/services/rest/restService.types.cjs +0 -0
- package/dist/services/rest/restService.types.mjs +1 -0
- package/dist/utility/index.cjs +1 -0
- package/dist/utility/index.mjs +2 -0
- package/dist/wallet/index.cjs +2 -0
- package/dist/wallet/index.mjs +2 -0
- package/dist/wallet/key/index.d.cts +1 -0
- package/dist/wallet/key/index.d.mts +1 -0
- package/dist/wallet/ledger/ledger.cjs +2 -1
- package/dist/wallet/ledger/ledger.cjs.map +1 -1
- package/dist/wallet/signer.cjs +0 -0
- package/dist/wallet/signer.mjs +1 -0
- package/dist/wallet/types/index.cjs +2 -0
- package/dist/wallet/types/index.d.cts +2 -0
- package/dist/wallet/types/index.d.mts +2 -0
- package/dist/wallet/types/index.mjs +3 -0
- package/dist/wallet/types/wallet.cjs +0 -0
- package/dist/wallet/types/wallet.mjs +1 -0
- package/dist/wallet/wallet.cjs +4 -2
- package/dist/wallet/wallet.cjs.map +1 -1
- package/dist/wallet/wallet.d.cts.map +1 -1
- package/dist/wallet/wallet.d.mts.map +1 -1
- package/dist/wallet/wallet.mjs +1 -0
- package/dist/wallet/wallet.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.mjs","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0) };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AAUA,MAAa,kBAAkB;AAmC/B,SAAS,eAAmB;AAC1B,QAAO;EAAE,UAAU,EAAE;EAAE,KAAK,KAAA;EAAW,YAAY,EAAE;EAAE,MAAM;EAAI;;AAGnE,M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GAAG,gBAAgB,OAAO,IAAI,GAAG,IAAI,WAAW,EAAE,EAAE;;CAGrF,OAAO,SAAmC;EACxC,MAAM,MAAW,EAAE;AACnB,MAAI,QAAQ,QAAQ,KAAA,EAClB,KAAI,MAAM,gBAAgB,QAAQ,IAAI;AAExC,SAAO;;CAGT,OAAyD,MAA2B;AAClF,SAAO,gBAAgB,YAAY,QAAS,EAAE,CAAS;;CAEzD,YAA8D,QAA4B;EACxF,MAAM,UAAU,2BAA2B;AAC3C,UAAQ,MAAM,OAAO,OAAO,IAAI,WAAW,EAAE;AAC7C,SAAO;;CAEV;AAED,SAAS,gBAAgB,KAAyB;AAChD,KAAK,WAAmB,OACtB,QAAO,WAAW,KAAM,WAAmB,OAAO,KAAK,KAAK,SAAS,CAAC;MACjE;EACL,MAAM,MAAM,WAAW,KAAK,IAAI;EAChC,MAAM,MAAM,IAAI,WAAW,IAAI,OAAO;AACtC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,EAAE,EAChC,KAAI,KAAK,IAAI,WAAW,EAAE;AAE5B,SAAO;;;AAIX,SAAS,gBAAgB,KAAyB;AAChD,KAAK,WAAmB,OACtB,QAAQ,WAAmB,OAAO,KAAK,IAAI,CAAC,SAAS,SAAS;MACzD;EACL,MAAM,MAAgB,EAAE;AACxB,MAAI,SAAS,SAAS;AACpB,OAAI,KAAK,WAAW,OAAO,aAAa,KAAK,CAAC;IAC9C;AACF,SAAO,WAAW,KAAK,IAAI,KAAK,GAAG,CAAC;;;AAgBxC,SAAS,MAAM,OAAqB;AAClC,QAAO,UAAU,QAAQ,UAAU,KAAA"}
|
|
1
|
+
{"version":3,"file":"tx.mjs","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0) };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AAUA,MAAa,kBAAkB;AAmC/B,SAAS,eAAmB;AAC1B,QAAO;EAAE,UAAU,EAAE;EAAE,KAAK;EAAW,YAAY,EAAE;EAAE,MAAM;EAAI;;AAGnE,MAAa,KAAqB;CAChC,OAAO,SAAa,SAAuB,IAAI,cAAc,EAAgB;AAC3E,OAAK,MAAM,KAAK,QAAQ,SACtB,KAAI,OAAO,GAAI,OAAO,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM;AAEjD,MAAI,QAAQ,QAAQ,OAClB,OAAM,OAAO,QAAQ,KAAK,OAAO,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM;AAE5D,OAAK,MAAM,KAAK,QAAQ,WACtB,aAAY,OAAO,GAAI,OAAO,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM;AAEzD,MAAI,QAAQ,SAAS,GACnB,QAAO,OAAO,GAAG,CAAC,OAAO,QAAQ,KAAK;AAExC,SAAO;;CAGT,OAAO,OAAkC,QAAqB;EAC5D,MAAM,SAAS,iBAAiB,eAAe,QAAQ,IAAI,aAAa,MAAM;EAC9E,MAAM,MAAM,WAAW,SAAY,OAAO,MAAM,OAAO,MAAM;EAC7D,MAAM,UAAU,cAAc;AAC9B,SAAO,OAAO,MAAM,KAAK;GACvB,MAAM,MAAM,OAAO,QAAQ;AAC3B,WAAQ,QAAQ,GAAhB;IACE,KAAK;AAC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AAO,aAAa,KAAK,CAAC;IAC9C;AACF,SAAO,WAAW,KAAK,IAAI,KAAK,GAAG,CAAC;;;AAgBxC,SAAS,MAAM,OAAqB;AAClC,QAAO,UAAU,QAAQ,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./errors.cjs");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, MemoTooLargeError, NoSignaturesError, OutOfGasError, TM2Error, TooManySignaturesError, TxDecodeError, UnauthorizedError, UnknownAddressError, UnknownRequestError } from "./errors.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, MemoTooLargeError, NoSignaturesError, OutOfGasError, TM2Error, TooManySignaturesError, TxDecodeError, UnauthorizedError, UnknownAddressError, UnknownRequestError } from "./errors.mjs";
|
package/dist/provider/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require("./endpoints.cjs");
|
|
2
2
|
require("./errors/errors.cjs");
|
|
3
|
+
require("./errors/index.cjs");
|
|
3
4
|
require("./types/abci.cjs");
|
|
5
|
+
require("./types/index.cjs");
|
|
4
6
|
require("./utility/adapters.cjs");
|
|
5
7
|
require("./utility/requests.utility.cjs");
|
|
6
8
|
require("./utility/provider.utility.cjs");
|
package/dist/provider/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import "./endpoints.mjs";
|
|
2
2
|
import "./errors/errors.mjs";
|
|
3
|
+
import "./errors/index.mjs";
|
|
3
4
|
import "./types/abci.mjs";
|
|
5
|
+
import "./types/index.mjs";
|
|
4
6
|
import "./utility/adapters.mjs";
|
|
5
7
|
import "./utility/requests.utility.mjs";
|
|
6
8
|
import "./utility/provider.utility.mjs";
|
|
@@ -3,6 +3,7 @@ require("../proto/index.cjs");
|
|
|
3
3
|
const require_endpoints = require("./endpoints.cjs");
|
|
4
4
|
const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs");
|
|
5
5
|
const require_abci = require("./types/abci.cjs");
|
|
6
|
+
require("./types/index.cjs");
|
|
6
7
|
const require_errors_utility = require("./utility/errors.utility.cjs");
|
|
7
8
|
const require_adapters = require("./utility/adapters.cjs");
|
|
8
9
|
const require_requests_utility = require("./utility/requests.utility.cjs");
|
|
@@ -20,73 +21,89 @@ var BaseTm2Provider = class {
|
|
|
20
21
|
}
|
|
21
22
|
async estimateGas(tx) {
|
|
22
23
|
const encodedTx = require_requests_utility.uint8ArrayToBase64(require_tx.Tx.encode(tx).finish());
|
|
23
|
-
const
|
|
24
|
+
const rpcResponse = await this.client.abciQuery({
|
|
24
25
|
path: ".app/simulate",
|
|
25
26
|
data: new TextEncoder().encode(encodedTx),
|
|
26
27
|
height: 0,
|
|
27
28
|
prove: false
|
|
28
|
-
})
|
|
29
|
+
});
|
|
30
|
+
const abciResponse = require_adapters.adaptAbciQueryResponse(rpcResponse);
|
|
31
|
+
const simulateResult = require_provider_utility.extractSimulateFromResponse(abciResponse);
|
|
29
32
|
const resultErrorKey = simulateResult.response_base?.error?.type_url;
|
|
30
33
|
if (resultErrorKey) throw require_errors_utility.constructRequestError(resultErrorKey);
|
|
31
34
|
return simulateResult.gas_used;
|
|
32
35
|
}
|
|
33
36
|
async getBalance(address, denomination, height) {
|
|
34
|
-
|
|
37
|
+
const rpcResponse = await this.client.abciQuery({
|
|
35
38
|
path: `bank/balances/${address}`,
|
|
36
39
|
data: new Uint8Array(),
|
|
37
40
|
height: height ? height : 0,
|
|
38
41
|
prove: false
|
|
39
|
-
})
|
|
42
|
+
});
|
|
43
|
+
const abciResponse = require_adapters.adaptAbciQueryResponse(rpcResponse);
|
|
44
|
+
return require_provider_utility.extractBalanceFromResponse(abciResponse.response.ResponseBase.Data, denomination ? denomination : "ugnot");
|
|
40
45
|
}
|
|
41
46
|
async getBlock(height) {
|
|
42
|
-
|
|
47
|
+
const rpcResponse = await this.client.block(height);
|
|
48
|
+
return require_adapters.adaptBlockResponse(rpcResponse);
|
|
43
49
|
}
|
|
44
50
|
async getBlockResult(height) {
|
|
45
|
-
|
|
51
|
+
const rpcResponse = await this.client.blockResults(height);
|
|
52
|
+
return require_adapters.adaptBlockResultsResponse(rpcResponse);
|
|
46
53
|
}
|
|
47
54
|
async getBlockNumber() {
|
|
48
55
|
const status = await this.getStatus();
|
|
49
56
|
return parseInt(status.sync_info.latest_block_height);
|
|
50
57
|
}
|
|
51
58
|
async getConsensusParams(height) {
|
|
52
|
-
|
|
59
|
+
const rpcResponse = await this.client.consensusParams(height);
|
|
60
|
+
return require_adapters.adaptConsensusParamsResponse(rpcResponse);
|
|
53
61
|
}
|
|
54
62
|
getGasPrice() {
|
|
55
63
|
return Promise.reject("not supported");
|
|
56
64
|
}
|
|
57
65
|
async getNetwork() {
|
|
58
|
-
|
|
66
|
+
const rpcResponse = await this.client.netInfo();
|
|
67
|
+
return require_adapters.adaptNetInfoResponse(rpcResponse);
|
|
59
68
|
}
|
|
60
69
|
async getAccountSequence(address, height) {
|
|
61
|
-
|
|
70
|
+
const rpcResponse = await this.client.abciQuery({
|
|
62
71
|
path: `auth/accounts/${address}`,
|
|
63
72
|
data: new Uint8Array(),
|
|
64
73
|
height: height ? height : 0,
|
|
65
74
|
prove: false
|
|
66
|
-
})
|
|
75
|
+
});
|
|
76
|
+
const abciResponse = require_adapters.adaptAbciQueryResponse(rpcResponse);
|
|
77
|
+
return require_provider_utility.extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);
|
|
67
78
|
}
|
|
68
79
|
async getAccountNumber(address, height) {
|
|
69
|
-
|
|
80
|
+
const rpcResponse = await this.client.abciQuery({
|
|
70
81
|
path: `auth/accounts/${address}`,
|
|
71
82
|
data: new Uint8Array(),
|
|
72
83
|
height: height ? height : 0,
|
|
73
84
|
prove: false
|
|
74
|
-
})
|
|
85
|
+
});
|
|
86
|
+
const abciResponse = require_adapters.adaptAbciQueryResponse(rpcResponse);
|
|
87
|
+
return require_provider_utility.extractAccountNumberFromResponse(abciResponse.response.ResponseBase.Data);
|
|
75
88
|
}
|
|
76
89
|
async getAccount(address, height) {
|
|
77
|
-
|
|
90
|
+
const rpcResponse = await this.client.abciQuery({
|
|
78
91
|
path: `auth/accounts/${address}`,
|
|
79
92
|
data: new Uint8Array(),
|
|
80
93
|
height: height ? height : 0,
|
|
81
94
|
prove: false
|
|
82
|
-
})
|
|
95
|
+
});
|
|
96
|
+
const abciResponse = require_adapters.adaptAbciQueryResponse(rpcResponse);
|
|
97
|
+
return require_provider_utility.extractAccountFromResponse(abciResponse.response.ResponseBase.Data);
|
|
83
98
|
}
|
|
84
99
|
async getStatus() {
|
|
85
|
-
|
|
100
|
+
const rpcResponse = await this.client.status();
|
|
101
|
+
return require_adapters.adaptStatusResponse(rpcResponse);
|
|
86
102
|
}
|
|
87
103
|
async getTransaction(hash) {
|
|
88
104
|
const hashBytes = Uint8Array.from((hash.match(/.{1,2}/g) ?? []).map((byte) => parseInt(byte, 16)));
|
|
89
|
-
|
|
105
|
+
const rpcResponse = await this.client.tx({ hash: hashBytes });
|
|
106
|
+
return require_adapters.adaptTxResponse(rpcResponse);
|
|
90
107
|
}
|
|
91
108
|
async sendTransaction(tx, endpoint) {
|
|
92
109
|
const txBytes = Uint8Array.from(Buffer.from(tx, "base64"));
|
|
@@ -97,7 +114,8 @@ var BaseTm2Provider = class {
|
|
|
97
114
|
}
|
|
98
115
|
}
|
|
99
116
|
async broadcastTxSync(txBytes) {
|
|
100
|
-
const
|
|
117
|
+
const rpcResponse = await this.client.broadcastTxSync({ tx: txBytes });
|
|
118
|
+
const response = require_adapters.adaptBroadcastTxSyncResponse(rpcResponse);
|
|
101
119
|
if (response.error) {
|
|
102
120
|
const errType = response.error[require_abci.ABCIErrorKey];
|
|
103
121
|
const log = response.Log;
|
|
@@ -106,7 +124,8 @@ var BaseTm2Provider = class {
|
|
|
106
124
|
return response;
|
|
107
125
|
}
|
|
108
126
|
async broadcastTxCommit(txBytes) {
|
|
109
|
-
const
|
|
127
|
+
const rpcResponse = await this.client.broadcastTxCommit({ tx: txBytes });
|
|
128
|
+
const response = require_adapters.adaptBroadcastTxCommitResponse(rpcResponse);
|
|
110
129
|
const { check_tx, deliver_tx } = response;
|
|
111
130
|
if (check_tx.ResponseBase.Error) {
|
|
112
131
|
const errType = check_tx.ResponseBase.Error[require_abci.ABCIErrorKey];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.cjs","names":["uint8ArrayToBase64","Tx","extractSimulateFromResponse","adaptAbciQueryResponse","constructRequestError","extractBalanceFromResponse","adaptBlockResponse","adaptBlockResultsResponse","adaptConsensusParamsResponse","adaptNetInfoResponse","extractSequenceFromResponse","extractAccountNumberFromResponse","extractAccountFromResponse","adaptStatusResponse","adaptTxResponse","TransactionEndpoint","adaptBroadcastTxSyncResponse","ABCIErrorKey","adaptBroadcastTxCommitResponse","waitForTransaction"],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;+CAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAYA,yBAAAA,mBAAmBC,WAAAA,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAS5D,MAAM,iBAAiBC,yBAAAA,4BADYC,iBAAAA,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC,CAEoE,CACN;EAEhE,MAAM,iBAAiB,eAAe,eAAe,OAAO;AAC5D,MAAI,eACF,OAAMC,uBAAAA,sBAAsB,eAAe;AAG7C,SAAO,eAAe;;CAGxB,MAAM,WACJ,SACA,cACA,QACiB;AAUjB,SAAOC,yBAAAA,2BAF4BF,iBAAAA,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM,iBAAiB;GACvB,MAAM,IAAI,YAAY;GACtB,QAAQ,SAAS,SAAS;GAC1B,OAAO;GACR,CAAC,CAEoE,CAGvD,SAAS,aAAa,MACnC,eAAe,eAAe,QAC/B;;CAGH,MAAM,SAAS,QAAoC;AAEjD,SAAOG,iBAAAA,mBADa,MAAM,KAAK,OAAO,MAAM,OAAO,CACb;;CAGxC,MAAM,eAAe,QAAsC;AAEzD,SAAOC,iBAAAA,0BADa,MAAM,KAAK,OAAO,aAAa,OAAO,CACb;;CAG/C,MAAM,iBAAkC;EACtC,MAAM,SAAS,MAAM,KAAK,WAAW;AACrC,SAAO,SAAS,O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,WACP,CAAC,CACiC;;CAGrC,MAAM,gBACJ,IACA,UAC+C;EAC/C,MAAM,UAAU,WAAW,KAAK,OAAO,KAAK,IAAI,SAAS,CAAC;AAE1D,UAAQ,UAAR;GACE,KAAKC,kBAAAA,oBAAoB,oBACvB,QAAO,KAAK,kBAAkB,QAAQ;GACxC,KAAKA,kBAAAA,oBAAoB;GACzB,QACE,QAAO,KAAK,gBAAgB,QAAQ;;;CAI1C,MAAc,gBACZ,SACgC;EAIhC,MAAM,WAAWC,iBAAAA,6BAHG,MAAM,KAAK,OAAO,gBAAgB,EACpD,IAAI,SACL,CAAC,CACwD;AAE1D,MAAI,SAAS,OAAO;GAClB,MAAM,UAAkB,SAAS,MAAMC,aAAAA;GACvC,MAAM,MAAc,SAAS;AAE7B,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAc,kBACZ,SACkC;EAIlC,MAAM,WAAWc,iBAAAA,+BAHG,MAAM,KAAK,OAAO,kBAAkB,EACtD,IAAI,SACL,CAAC,CAC0D;EAE5D,MAAM,EACJ,UAAU,eACR;AAEJ,MAAI,SAAS,aAAa,OAAO;GAC/B,MAAM,UAAkB,SAAS,aAAa,MAAMD,aAAAA;GACpD,MAAM,MAAc,SAAS,aAAa;AAE1C,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,MAAI,WAAW,aAAa,OAAO;GACjC,MAAM,UAAkB,WAAW,aAAa,MAAMa,aAAAA;GACtD,MAAM,MAAc,WAAW,aAAa;AAE5C,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAOe,yBAAAA,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"provider.cjs","names":["uint8ArrayToBase64","Tx","adaptAbciQueryResponse","extractSimulateFromResponse","constructRequestError","extractBalanceFromResponse","adaptBlockResponse","adaptBlockResultsResponse","adaptConsensusParamsResponse","adaptNetInfoResponse","extractSequenceFromResponse","extractAccountNumberFromResponse","extractAccountFromResponse","adaptStatusResponse","adaptTxResponse","TransactionEndpoint","adaptBroadcastTxSyncResponse","ABCIErrorKey","adaptBroadcastTxCommitResponse","waitForTransaction"],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;+CAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAYA,yBAAAA,mBAAmBC,WAAAA,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAC5D,MAAM,cAAc,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC;E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B,QAAQ;;;CAI1C,MAAc,gBACZ,SACgC;EAChC,MAAM,cAAc,MAAM,KAAK,OAAO,gBAAgB,EACpD,IAAI,SACL,CAAC;EACF,MAAM,WAAWC,iBAAAA,6BAA6B,YAAY;AAE1D,MAAI,SAAS,OAAO;GAClB,MAAM,UAAkB,SAAS,MAAMC,aAAAA;GACvC,MAAM,MAAc,SAAS;AAE7B,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAc,kBACZ,SACkC;EAClC,MAAM,cAAc,MAAM,KAAK,OAAO,kBAAkB,EACtD,IAAI,SACL,CAAC;EACF,MAAM,WAAWc,iBAAAA,+BAA+B,YAAY;EAE5D,MAAM,EACJ,UAAU,eACR;AAEJ,MAAI,SAAS,aAAa,OAAO;GAC/B,MAAM,UAAkB,SAAS,aAAa,MAAMD,aAAAA;GACpD,MAAM,MAAc,SAAS,aAAa;AAE1C,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,MAAI,WAAW,aAAa,OAAO;GACjC,MAAM,UAAkB,WAAW,aAAa,MAAMa,aAAAA;GACtD,MAAM,MAAc,WAAW,aAAa;AAE5C,SAAMb,uBAAAA,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAOe,yBAAAA,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.cts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA
|
|
1
|
+
{"version":3,"file":"provider.d.cts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA;;AAAjB;;;;;;EAUE,UAAA,CACE,OAAA,UACA,YAAA,WACA,MAAA,YACC,OAAA;EA4B2C;;;;;;;EAnB9C,kBAAA,CAAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAiDV;;;;;;;;E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CAAA,GAAc,OAAA,CAAQ,WAAA;EAKtB,kBAAA,CAAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAYtD,gBAAA,CAAiB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAcpD,UAAA,CAAW,OAAA,UAAiB,MAAA,YAAkB,OAAA,CAAQ,WAAA;EAYtD,SAAA,CAAA,GAAa,OAAA,CAAQ,MAAA;EAKrB,cAAA,CAAe,IAAA,WAAe,OAAA,CAAQ,QAAA;EAUtC,eAAA,iBAAgC,uBAAA,CAAA,CACpC,EAAA,UACA,QAAA,EAAU,CAAA,GACT,OAAA,CAAQ,uBAAA,CAAwB,CAAA;EAAA,QAYrB,eAAA;EAAA,QAkBA,iBAAA;EA6BR,kBAAA,CACJ,IAAA,UACA,UAAA,WACA,OAAA,YACC,OAAA,CAAQ,EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.mts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA
|
|
1
|
+
{"version":3,"file":"provider.d.mts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA;;AAAjB;;;;;;EAUE,UAAA,CACE,OAAA,UACA,YAAA,WACA,MAAA,YACC,OAAA;EA4B2C;;;;;;;EAnB9C,kBAAA,CAAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAiDV;;;;;;;;EAvC5C,gBAAA,CAAiB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAsEtB;;;;;;;EA7D9B,UAAA,CAAW,OAAA,UAAiB,MAAA,YAAkB,OAAA,CAAQ,WAAA;EA/BpD;;;;EAqCF,QAAA,CAAS,MAAA,WAAiB,OAAA,CAAQ,SAAA;EAzBf;;;;EA+BnB,cAAA,CAAe,MAAA,WAAiB,OAAA,CAAQ,WAAA;EArBN;;;EA0BlC,cAAA,IAAkB,OAAA;EAjBU;;;EAwB5B,UAAA,IAAc,OAAA,CAA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,EAAA,UACA,QAAA,EAAU,CAAA,GACT,OAAA,CAAQ,uBAAA,CAAwB,CAAA;EAAA,QAYrB,eAAA;EAAA,QAkBA,iBAAA;EA6BR,kBAAA,CACJ,IAAA,UACA,UAAA,WACA,OAAA,YACC,OAAA,CAAQ,EAAA;AAAA"}
|
|
@@ -3,6 +3,7 @@ import "../proto/index.mjs";
|
|
|
3
3
|
import { TransactionEndpoint } from "./endpoints.mjs";
|
|
4
4
|
import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs";
|
|
5
5
|
import { ABCIErrorKey } from "./types/abci.mjs";
|
|
6
|
+
import "./types/index.mjs";
|
|
6
7
|
import { constructRequestError } from "./utility/errors.utility.mjs";
|
|
7
8
|
import { adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse } from "./utility/adapters.mjs";
|
|
8
9
|
import { uint8ArrayToBase64 } from "./utility/requests.utility.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.mjs","names":[],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;wBAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAY,mBAAmB,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAS5D,MAAM,iBAAiB,4BADY,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC,CAEoE,CACN;EAEhE,MAAM,iBAAiB,eAAe,eAAe,OAAO;AAC5D,MAAI,eACF,OAAM,sBAAsB,eAAe;AAG7C,SAAO,eAAe;;CAGxB,MAAM,WACJ,SACA,cACA,QACiB;AAUjB,SAAO,2BAF4B,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM,iBAAiB;GACvB,MAAM,IAAI,YAAY;GACtB,QAAQ,SAAS,SAAS;GAC1B,OAAO;GACR,CAAC,CAEoE,CAGvD,SAAS,aAAa,MACnC,eAAe,eAAe,QAC/B;;CAGH,MAAM,SAAS,QAAoC;AAEjD,SAAO,mBADa,MAAM,KAAK,OAAO,MAAM,OAAO,CACb;;CAGxC,MAAM,eAAe,QAAsC;AAEzD,SAAO,0BADa,MAAM,KAAK,OAAO,aAAa,OAAO,CACb;;CAG/C,MAAM,iBAAkC;EACtC,MAAM,SAAS,MAAM,KAAK,WAAW;AACrC,SAAO,SAAS,OAAO,UAAU,oBAAoB;;CAGvD,MAAM,mBAAmB,QAA0C;AAEjE,SAAO,6BADa,MAAM,KAAK,OA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QAAQ;GACxC,KAAK,oBAAoB;GACzB,QACE,QAAO,KAAK,gBAAgB,QAAQ;;;CAI1C,MAAc,gBACZ,SACgC;EAIhC,MAAM,WAAW,6BAHG,MAAM,KAAK,OAAO,gBAAgB,EACpD,IAAI,SACL,CAAC,CACwD;AAE1D,MAAI,SAAS,OAAO;GAClB,MAAM,UAAkB,SAAS,MAAM;GACvC,MAAM,MAAc,SAAS;AAE7B,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAc,kBACZ,SACkC;EAIlC,MAAM,WAAW,+BAHG,MAAM,KAAK,OAAO,kBAAkB,EACtD,IAAI,SACL,CAAC,CAC0D;EAE5D,MAAM,EACJ,UAAU,eACR;AAEJ,MAAI,SAAS,aAAa,OAAO;GAC/B,MAAM,UAAkB,SAAS,aAAa,MAAM;GACpD,MAAM,MAAc,SAAS,aAAa;AAE1C,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,MAAI,WAAW,aAAa,OAAO;GACjC,MAAM,UAAkB,WAAW,aAAa,MAAM;GACtD,MAAM,MAAc,WAAW,aAAa;AAE5C,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAO,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"provider.mjs","names":[],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;wBAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAY,mBAAmB,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAS5D,MAAM,iBAAiB,4BADY,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC,CAEoE,CACN;EAEhE,MAAM,iBAAiB,eAAe,eAAe,OAAO;AAC5D,MAAI,eACF,OAAM,sBAAsB,eAAe;AAG7C,SAAO,eAAe;;CAGxB,MAAM,WACJ,SACA,cACA,QACiB;AAUjB,SAAO,2BAF4B,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM,iBAAiB;GACvB,MAAM,IAAI,YAAY;GACtB,QAAQ,SAAS,SAAS;GAC1B,OAAO;GACR,CAAC,CAEoE,CAGvD,SAAS,aAAa,MACnC,eAAe,eAAe,QAC/B;;CAGH,MAAM,SAAS,QAAoC;AAEjD,SAAO,mBADa,MAAM,KAAK,OAAO,MAAM,OAAO,CACb;;CAGxC,MAAM,eAAe,QAAsC;AAEzD,SAAO,0BADa,MAAM,KAAK,OAAO,aAAa,OAAO,CACb;;CAG/C,MAAM,iBAAkC;EACtC,MAAM,SAAS,MAAM,KAAK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WAAW,KAAK,OAAO,KAAK,IAAI,SAAS,CAAC;AAE1D,UAAQ,UAAR;GACE,KAAK,oBAAoB,oBACvB,QAAO,KAAK,kBAAkB,QAAQ;GACxC,KAAK,oBAAoB;GACzB,QACE,QAAO,KAAK,gBAAgB,QAAQ;;;CAI1C,MAAc,gBACZ,SACgC;EAIhC,MAAM,WAAW,6BAHG,MAAM,KAAK,OAAO,gBAAgB,EACpD,IAAI,SACL,CAAC,CACwD;AAE1D,MAAI,SAAS,OAAO;GAClB,MAAM,UAAkB,SAAS,MAAM;GACvC,MAAM,MAAc,SAAS;AAE7B,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAc,kBACZ,SACkC;EAIlC,MAAM,WAAW,+BAHG,MAAM,KAAK,OAAO,kBAAkB,EACtD,IAAI,SACL,CAAC,CAC0D;EAE5D,MAAM,EACJ,UAAU,eACR;AAEJ,MAAI,SAAS,aAAa,OAAO;GAC/B,MAAM,UAAkB,SAAS,aAAa,MAAM;GACpD,MAAM,MAAc,SAAS,aAAa;AAE1C,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,MAAI,WAAW,aAAa,OAAO;GACjC,MAAM,UAAkB,WAAW,aAAa,MAAM;GACtD,MAAM,MAAc,WAAW,aAAa;AAE5C,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAO,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ABCIAccount, ABCIErrorKey, ABCIResponse, ABCIResponseBase } from "./abci.cjs";
|
|
2
|
+
import { BeginBlock, Block, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, ConsensusParams, ConsensusState, DeliverTx, EndBlock, NetworkInfo, PrecommitInfo, Status, TxResult } from "./common.cjs";
|
|
3
|
+
import { RPCError, RPCRequest, RPCResponse } from "./jsonrpc.cjs";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ABCIAccount, ABCIErrorKey, ABCIResponse, ABCIResponseBase } from "./abci.mjs";
|
|
2
|
+
import { BeginBlock, Block, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, ConsensusParams, ConsensusState, DeliverTx, EndBlock, NetworkInfo, PrecommitInfo, Status, TxResult } from "./common.mjs";
|
|
3
|
+
import { RPCError, RPCRequest, RPCResponse } from "./jsonrpc.mjs";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.utility.cjs","names":["InternalError","TxDecodeError","InvalidSequenceError","UnauthorizedError","InsufficientFundsError","UnknownRequestError","InvalidAddressError","UnknownAddressError","InvalidPubKeyError","InsufficientCoinsError","InvalidCoinsError","InvalidGasWantedError","OutOfGasError","MemoTooLargeError","InsufficientFeeError","TooManySignaturesError","NoSignaturesError","GasOverflowError","TM2Error"],"sources":["../../../src/provider/utility/errors.utility.ts"],"sourcesContent":["import {\n GasOverflowError,\n InsufficientCoinsError,\n InsufficientFeeError,\n InsufficientFundsError,\n InternalError,\n InvalidAddressError,\n InvalidCoinsError,\n InvalidGasWantedError,\n InvalidPubKeyError,\n InvalidSequenceError,\n MemoTooLargeError,\n NoSignaturesError,\n OutOfGasError,\n TM2Error,\n TooManySignaturesError,\n TxDecodeError,\n UnauthorizedError,\n UnknownAddressError,\n UnknownRequestError,\n} from \"../errors/index.js\";\n\n/**\n * Constructs the appropriate Tendermint2\n * error based on the error ID.\n * Error IDs retrieved from:\n * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38\n * @param {string} errorID the proto ID of the error\n * @param {string} [log] the log associated with the error, if any\n * @returns {TM2Error}\n */\nexport const constructRequestError = (\n errorID: string,\n log?: string,\n): TM2Error => {\n switch (errorID) {\n case \"/std.InternalError\":\n return new InternalError(log);\n case \"/std.TxDecodeError\":\n return new TxDecodeError(log);\n case \"/std.InvalidSequenceError\":\n return new InvalidSequenceError(log);\n case \"/std.UnauthorizedError\":\n return new UnauthorizedError(log);\n case \"/std.InsufficientFundsError\":\n return new InsufficientFundsError(log);\n case \"/std.UnknownRequestError\":\n return new UnknownRequestError(log);\n case \"/std.InvalidAddressError\":\n return new InvalidAddressError(log);\n case \"/std.UnknownAddressError\":\n return new UnknownAddressError(log);\n case \"/std.InvalidPubKeyError\":\n return new InvalidPubKeyError(log);\n case \"/std.InsufficientCoinsError\":\n return new InsufficientCoinsError(log);\n case \"/std.InvalidCoinsError\":\n return new InvalidCoinsError(log);\n case \"/std.InvalidGasWantedError\":\n return new InvalidGasWantedError(log);\n case \"/std.OutOfGasError\":\n return new OutOfGasError(log);\n case \"/std.MemoTooLargeError\":\n return new MemoTooLargeError(log);\n case \"/std.InsufficientFeeError\":\n return new InsufficientFeeError(log);\n case \"/std.TooManySignaturesError\":\n return new TooManySignaturesError(log);\n case \"/std.NoSignaturesError\":\n return new NoSignaturesError(log);\n case \"/std.GasOverflowError\":\n return new GasOverflowError(log);\n default:\n return new TM2Error(`unknown error: ${errorID}`, log);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.utility.cjs","names":["InternalError","TxDecodeError","InvalidSequenceError","UnauthorizedError","InsufficientFundsError","UnknownRequestError","InvalidAddressError","UnknownAddressError","InvalidPubKeyError","InsufficientCoinsError","InvalidCoinsError","InvalidGasWantedError","OutOfGasError","MemoTooLargeError","InsufficientFeeError","TooManySignaturesError","NoSignaturesError","GasOverflowError","TM2Error"],"sources":["../../../src/provider/utility/errors.utility.ts"],"sourcesContent":["import {\n GasOverflowError,\n InsufficientCoinsError,\n InsufficientFeeError,\n InsufficientFundsError,\n InternalError,\n InvalidAddressError,\n InvalidCoinsError,\n InvalidGasWantedError,\n InvalidPubKeyError,\n InvalidSequenceError,\n MemoTooLargeError,\n NoSignaturesError,\n OutOfGasError,\n TM2Error,\n TooManySignaturesError,\n TxDecodeError,\n UnauthorizedError,\n UnknownAddressError,\n UnknownRequestError,\n} from \"../errors/index.js\";\n\n/**\n * Constructs the appropriate Tendermint2\n * error based on the error ID.\n * Error IDs retrieved from:\n * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38\n * @param {string} errorID the proto ID of the error\n * @param {string} [log] the log associated with the error, if any\n * @returns {TM2Error}\n */\nexport const constructRequestError = (\n errorID: string,\n log?: string,\n): TM2Error => {\n switch (errorID) {\n case \"/std.InternalError\":\n return new InternalError(log);\n case \"/std.TxDecodeError\":\n return new TxDecodeError(log);\n case \"/std.InvalidSequenceError\":\n return new InvalidSequenceError(log);\n case \"/std.UnauthorizedError\":\n return new UnauthorizedError(log);\n case \"/std.InsufficientFundsError\":\n return new InsufficientFundsError(log);\n case \"/std.UnknownRequestError\":\n return new UnknownRequestError(log);\n case \"/std.InvalidAddressError\":\n return new InvalidAddressError(log);\n case \"/std.UnknownAddressError\":\n return new UnknownAddressError(log);\n case \"/std.InvalidPubKeyError\":\n return new InvalidPubKeyError(log);\n case \"/std.InsufficientCoinsError\":\n return new InsufficientCoinsError(log);\n case \"/std.InvalidCoinsError\":\n return new InvalidCoinsError(log);\n case \"/std.InvalidGasWantedError\":\n return new InvalidGasWantedError(log);\n case \"/std.OutOfGasError\":\n return new OutOfGasError(log);\n case \"/std.MemoTooLargeError\":\n return new MemoTooLargeError(log);\n case \"/std.InsufficientFeeError\":\n return new InsufficientFeeError(log);\n case \"/std.TooManySignaturesError\":\n return new TooManySignaturesError(log);\n case \"/std.NoSignaturesError\":\n return new NoSignaturesError(log);\n case \"/std.GasOverflowError\":\n return new GasOverflowError(log);\n default:\n return new TM2Error(`unknown error: ${errorID}`, log);\n }\n};\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAa,yBACX,SACA,QACa;AACb,SAAQ,SAAR;EACE,KAAK,qBACH,QAAO,IAAIA,eAAAA,cAAc,IAAI;EAC/B,KAAK,qBACH,QAAO,IAAIC,eAAAA,cAAc,IAAI;EAC/B,KAAK,4BACH,QAAO,IAAIC,eAAAA,qBAAqB,IAAI;EACtC,KAAK,yBACH,QAAO,IAAIC,eAAAA,kBAAkB,IAAI;EACnC,KAAK,8BACH,QAAO,IAAIC,eAAAA,uBAAuB,IAAI;EACxC,KAAK,2BACH,QAAO,IAAIC,eAAAA,oBAAoB,IAAI;EACrC,KAAK,2BACH,QAAO,IAAIC,eAAAA,oBAAoB,IAAI;EACrC,KAAK,2BACH,QAAO,IAAIC,eAAAA,oBAAoB,IAAI;EACrC,KAAK,0BACH,QAAO,IAAIC,eAAAA,mBAAmB,IAAI;EACpC,KAAK,8BACH,QAAO,IAAIC,eAAAA,uBAAuB,IAAI;EACxC,KAAK,yBACH,QAAO,IAAIC,eAAAA,kBAAkB,IAAI;EACnC,KAAK,6BACH,QAAO,IAAIC,eAAAA,sBAAsB,IAAI;EACvC,KAAK,qBACH,QAAO,IAAIC,eAAAA,cAAc,IAAI;EAC/B,KAAK,yBACH,QAAO,IAAIC,eAAAA,kBAAkB,IAAI;EACnC,KAAK,4BACH,QAAO,IAAIC,eAAAA,qBAAqB,IAAI;EACtC,KAAK,8BACH,QAAO,IAAIC,eAAAA,uBAAuB,IAAI;EACxC,KAAK,yBACH,QAAO,IAAIC,eAAAA,kBAAkB,IAAI;EACnC,KAAK,wBACH,QAAO,IAAIC,eAAAA,iBAAiB,IAAI;EAClC,QACE,QAAO,IAAIC,eAAAA,SAAS,kBAAkB,WAAW,IAAI"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, MemoTooLargeError, NoSignaturesError, OutOfGasError, TM2Error, TooManySignaturesError, TxDecodeError, UnauthorizedError, UnknownAddressError, UnknownRequestError } from "../errors/errors.mjs";
|
|
2
|
+
import "../errors/index.mjs";
|
|
2
3
|
//#region src/provider/utility/errors.utility.ts
|
|
3
4
|
/**
|
|
4
5
|
* Constructs the appropriate Tendermint2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.utility.mjs","names":[],"sources":["../../../src/provider/utility/errors.utility.ts"],"sourcesContent":["import {\n GasOverflowError,\n InsufficientCoinsError,\n InsufficientFeeError,\n InsufficientFundsError,\n InternalError,\n InvalidAddressError,\n InvalidCoinsError,\n InvalidGasWantedError,\n InvalidPubKeyError,\n InvalidSequenceError,\n MemoTooLargeError,\n NoSignaturesError,\n OutOfGasError,\n TM2Error,\n TooManySignaturesError,\n TxDecodeError,\n UnauthorizedError,\n UnknownAddressError,\n UnknownRequestError,\n} from \"../errors/index.js\";\n\n/**\n * Constructs the appropriate Tendermint2\n * error based on the error ID.\n * Error IDs retrieved from:\n * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38\n * @param {string} errorID the proto ID of the error\n * @param {string} [log] the log associated with the error, if any\n * @returns {TM2Error}\n */\nexport const constructRequestError = (\n errorID: string,\n log?: string,\n): TM2Error => {\n switch (errorID) {\n case \"/std.InternalError\":\n return new InternalError(log);\n case \"/std.TxDecodeError\":\n return new TxDecodeError(log);\n case \"/std.InvalidSequenceError\":\n return new InvalidSequenceError(log);\n case \"/std.UnauthorizedError\":\n return new UnauthorizedError(log);\n case \"/std.InsufficientFundsError\":\n return new InsufficientFundsError(log);\n case \"/std.UnknownRequestError\":\n return new UnknownRequestError(log);\n case \"/std.InvalidAddressError\":\n return new InvalidAddressError(log);\n case \"/std.UnknownAddressError\":\n return new UnknownAddressError(log);\n case \"/std.InvalidPubKeyError\":\n return new InvalidPubKeyError(log);\n case \"/std.InsufficientCoinsError\":\n return new InsufficientCoinsError(log);\n case \"/std.InvalidCoinsError\":\n return new InvalidCoinsError(log);\n case \"/std.InvalidGasWantedError\":\n return new InvalidGasWantedError(log);\n case \"/std.OutOfGasError\":\n return new OutOfGasError(log);\n case \"/std.MemoTooLargeError\":\n return new MemoTooLargeError(log);\n case \"/std.InsufficientFeeError\":\n return new InsufficientFeeError(log);\n case \"/std.TooManySignaturesError\":\n return new TooManySignaturesError(log);\n case \"/std.NoSignaturesError\":\n return new NoSignaturesError(log);\n case \"/std.GasOverflowError\":\n return new GasOverflowError(log);\n default:\n return new TM2Error(`unknown error: ${errorID}`, log);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.utility.mjs","names":[],"sources":["../../../src/provider/utility/errors.utility.ts"],"sourcesContent":["import {\n GasOverflowError,\n InsufficientCoinsError,\n InsufficientFeeError,\n InsufficientFundsError,\n InternalError,\n InvalidAddressError,\n InvalidCoinsError,\n InvalidGasWantedError,\n InvalidPubKeyError,\n InvalidSequenceError,\n MemoTooLargeError,\n NoSignaturesError,\n OutOfGasError,\n TM2Error,\n TooManySignaturesError,\n TxDecodeError,\n UnauthorizedError,\n UnknownAddressError,\n UnknownRequestError,\n} from \"../errors/index.js\";\n\n/**\n * Constructs the appropriate Tendermint2\n * error based on the error ID.\n * Error IDs retrieved from:\n * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38\n * @param {string} errorID the proto ID of the error\n * @param {string} [log] the log associated with the error, if any\n * @returns {TM2Error}\n */\nexport const constructRequestError = (\n errorID: string,\n log?: string,\n): TM2Error => {\n switch (errorID) {\n case \"/std.InternalError\":\n return new InternalError(log);\n case \"/std.TxDecodeError\":\n return new TxDecodeError(log);\n case \"/std.InvalidSequenceError\":\n return new InvalidSequenceError(log);\n case \"/std.UnauthorizedError\":\n return new UnauthorizedError(log);\n case \"/std.InsufficientFundsError\":\n return new InsufficientFundsError(log);\n case \"/std.UnknownRequestError\":\n return new UnknownRequestError(log);\n case \"/std.InvalidAddressError\":\n return new InvalidAddressError(log);\n case \"/std.UnknownAddressError\":\n return new UnknownAddressError(log);\n case \"/std.InvalidPubKeyError\":\n return new InvalidPubKeyError(log);\n case \"/std.InsufficientCoinsError\":\n return new InsufficientCoinsError(log);\n case \"/std.InvalidCoinsError\":\n return new InvalidCoinsError(log);\n case \"/std.InvalidGasWantedError\":\n return new InvalidGasWantedError(log);\n case \"/std.OutOfGasError\":\n return new OutOfGasError(log);\n case \"/std.MemoTooLargeError\":\n return new MemoTooLargeError(log);\n case \"/std.InsufficientFeeError\":\n return new InsufficientFeeError(log);\n case \"/std.TooManySignaturesError\":\n return new TooManySignaturesError(log);\n case \"/std.NoSignaturesError\":\n return new NoSignaturesError(log);\n case \"/std.GasOverflowError\":\n return new GasOverflowError(log);\n default:\n return new TM2Error(`unknown error: ${errorID}`, log);\n }\n};\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAa,yBACX,SACA,QACa;AACb,SAAQ,SAAR;EACE,KAAK,qBACH,QAAO,IAAI,cAAc,IAAI;EAC/B,KAAK,qBACH,QAAO,IAAI,cAAc,IAAI;EAC/B,KAAK,4BACH,QAAO,IAAI,qBAAqB,IAAI;EACtC,KAAK,yBACH,QAAO,IAAI,kBAAkB,IAAI;EACnC,KAAK,8BACH,QAAO,IAAI,uBAAuB,IAAI;EACxC,KAAK,2BACH,QAAO,IAAI,oBAAoB,IAAI;EACrC,KAAK,2BACH,QAAO,IAAI,oBAAoB,IAAI;EACrC,KAAK,2BACH,QAAO,IAAI,oBAAoB,IAAI;EACrC,KAAK,0BACH,QAAO,IAAI,mBAAmB,IAAI;EACpC,KAAK,8BACH,QAAO,IAAI,uBAAuB,IAAI;EACxC,KAAK,yBACH,QAAO,IAAI,kBAAkB,IAAI;EACnC,KAAK,6BACH,QAAO,IAAI,sBAAsB,IAAI;EACvC,KAAK,qBACH,QAAO,IAAI,cAAc,IAAI;EAC/B,KAAK,yBACH,QAAO,IAAI,kBAAkB,IAAI;EACnC,KAAK,4BACH,QAAO,IAAI,qBAAqB,IAAI;EACtC,KAAK,8BACH,QAAO,IAAI,uBAAuB,IAAI;EACxC,KAAK,yBACH,QAAO,IAAI,kBAAkB,IAAI;EACnC,KAAK,wBACH,QAAO,IAAI,iBAAiB,IAAI;EAClC,QACE,QAAO,IAAI,SAAS,kBAAkB,WAAW,IAAI"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_abci = require("../../proto/tm2/abci.cjs");
|
|
2
3
|
const require_tx = require("../../proto/tm2/tx.cjs");
|
|
3
4
|
require("../../proto/index.cjs");
|
|
4
|
-
const require_abci = require("../types/abci.cjs");
|
|
5
|
+
const require_abci$1 = require("../types/abci.cjs");
|
|
6
|
+
require("../types/index.cjs");
|
|
5
7
|
const require_errors_utility = require("./errors.utility.cjs");
|
|
6
|
-
const require_abci$1 = require("../../proto/tm2/abci.cjs");
|
|
7
8
|
const require_requests_utility = require("./requests.utility.cjs");
|
|
8
9
|
let _cosmjs_crypto = require("@cosmjs/crypto");
|
|
9
10
|
//#region src/provider/utility/provider.utility.ts
|
|
@@ -67,11 +68,11 @@ const extractAccountFromResponse = (abciData) => {
|
|
|
67
68
|
const extractSimulateFromResponse = (abciResponse) => {
|
|
68
69
|
if (!abciResponse) throw new Error("abci data is not initialized");
|
|
69
70
|
const error = abciResponse.response?.ResponseBase?.Error;
|
|
70
|
-
if (error && error["@type"]) throw require_errors_utility.constructRequestError(error[require_abci.ABCIErrorKey]);
|
|
71
|
+
if (error && error["@type"]) throw require_errors_utility.constructRequestError(error[require_abci$1.ABCIErrorKey]);
|
|
71
72
|
const value = abciResponse.response.Value;
|
|
72
73
|
if (!value) throw new Error("abci data is not initialized");
|
|
73
74
|
try {
|
|
74
|
-
return require_requests_utility.parseProto(value, require_abci
|
|
75
|
+
return require_requests_utility.parseProto(value, require_abci.ResponseDeliverTx.decode);
|
|
75
76
|
} catch (e) {
|
|
76
77
|
throw new Error("unable to parse simulate response", { cause: e });
|
|
77
78
|
}
|
|
@@ -97,7 +98,8 @@ const waitForTransaction = async (provider, hash, fromHeight, timeout) => {
|
|
|
97
98
|
if (!block.block.data.txs || block.block.data.txs.length == 0) continue;
|
|
98
99
|
for (const tx of block.block.data.txs) {
|
|
99
100
|
const txRaw = require_requests_utility.base64ToUint8Array(tx);
|
|
100
|
-
|
|
101
|
+
const txHash = (0, _cosmjs_crypto.sha256)(txRaw);
|
|
102
|
+
if (require_requests_utility.uint8ArrayToBase64(txHash) == hash) {
|
|
101
103
|
clearInterval(fetchInterval);
|
|
102
104
|
resolve(require_tx.Tx.decode(txRaw));
|
|
103
105
|
}
|