@kontor/kontor-sdk 1.0.0-alpha.1 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js +10 -14
- package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/cjs/sdk/actions/public/test-mempool-accept.js +10 -0
- package/dist/cjs/sdk/actions/public/test-mempool-accept.js.map +1 -1
- package/dist/cjs/sdk/clients/decorators/public.js +2 -0
- package/dist/cjs/sdk/clients/decorators/public.js.map +1 -1
- package/dist/cjs/sdk/clients/transports/custom.js.map +1 -1
- package/dist/cjs/sdk/utils/build-rpc-request.js +1 -0
- package/dist/cjs/sdk/utils/build-rpc-request.js.map +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js +37 -23
- package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/esm/sdk/actions/public/test-mempool-accept.js +8 -32
- package/dist/esm/sdk/actions/public/test-mempool-accept.js.map +1 -1
- package/dist/esm/sdk/clients/decorators/public.js +2 -0
- package/dist/esm/sdk/clients/decorators/public.js.map +1 -1
- package/dist/esm/sdk/clients/transports/custom.js.map +1 -1
- package/dist/esm/sdk/utils/build-rpc-request.js +1 -0
- package/dist/esm/sdk/utils/build-rpc-request.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/src/sdk/actions/kontor/public/build-compose-call.js +5 -6
- package/dist/src/sdk/actions/kontor/public/build-compose-call.js.map +1 -1
- package/dist/src/sdk/actions/kontor/public/build-compose-query.js +30 -0
- package/dist/src/sdk/actions/kontor/public/build-compose-query.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/build-instruction-query.js +45 -0
- package/dist/src/sdk/actions/kontor/public/build-instruction-query.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/build-instruction.js +13 -16
- package/dist/src/sdk/actions/kontor/public/build-instruction.js.map +1 -1
- package/dist/src/sdk/actions/kontor/public/call-compose.js +38 -0
- package/dist/src/sdk/actions/kontor/public/call-compose.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/call-proc.js +6 -2
- package/dist/src/sdk/actions/kontor/public/call-proc.js.map +1 -1
- package/dist/src/sdk/actions/kontor/public/proc-contract.js +8 -5
- package/dist/src/sdk/actions/kontor/public/proc-contract.js.map +1 -1
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +37 -25
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/src/sdk/clients/decorators/kontor/public.js +6 -6
- package/dist/src/sdk/clients/decorators/kontor/public.js.map +1 -1
- package/dist/src/sdk/types/kontor.js +27 -1
- package/dist/src/sdk/types/kontor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/sdk/actions/kontor/wallet/sign-reveal.d.ts.map +1 -1
- package/dist/types/sdk/actions/public/test-mempool-accept.d.ts +14 -1
- package/dist/types/sdk/actions/public/test-mempool-accept.d.ts.map +1 -1
- package/dist/types/sdk/clients/decorators/public.d.ts +2 -0
- package/dist/types/sdk/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/sdk/clients/transports/custom.d.ts.map +1 -1
- package/dist/types/sdk/types/btc-rpc.d.ts +9 -1
- package/dist/types/sdk/types/btc-rpc.d.ts.map +1 -1
- package/dist/types/sdk/utils/build-rpc-request.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/sdk/actions/kontor/public/{build-compose-call.ts → build-compose-query.ts} +15 -25
- package/src/sdk/actions/kontor/public/{build-instruction.ts → build-instruction-query.ts} +35 -29
- package/src/sdk/actions/kontor/public/{call-proc.ts → call-compose.ts} +16 -19
- package/src/sdk/actions/kontor/public/proc-contract.ts +9 -6
- package/src/sdk/actions/kontor/wallet/sign-reveal.ts +49 -28
- package/src/sdk/actions/public/test-mempool-accept.ts +34 -31
- package/src/sdk/clients/decorators/kontor/public.ts +23 -23
- package/src/sdk/clients/decorators/public.ts +11 -0
- package/src/sdk/test/e2e.test.ts +193 -15
- package/src/sdk/types/btc-rpc.ts +12 -11
- package/src/sdk/types/kontor.ts +38 -0
- package/dist/src/exports/index.test.js +0 -10
- package/dist/src/exports/index.test.js.map +0 -1
- package/dist/src/sdk/accounts/hd-key-to-account.js +0 -20
- package/dist/src/sdk/accounts/hd-key-to-account.js.map +0 -1
- package/dist/src/sdk/accounts/mnemonic-to-account.js +0 -16
- package/dist/src/sdk/accounts/mnemonic-to-account.js.map +0 -1
- package/dist/src/sdk/accounts/mnemonic-to-account.test.js +0 -96
- package/dist/src/sdk/accounts/mnemonic-to-account.test.js.map +0 -1
- package/dist/src/sdk/accounts/to-local-account.js +0 -28
- package/dist/src/sdk/accounts/to-local-account.js.map +0 -1
- package/dist/src/sdk/accounts/types.js +0 -2
- package/dist/src/sdk/accounts/types.js.map +0 -1
- package/dist/src/sdk/accounts/utils/parse-account.js +0 -10
- package/dist/src/sdk/accounts/utils/parse-account.js.map +0 -1
- package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js +0 -14
- package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js.map +0 -1
- package/dist/src/sdk/accounts/utils/sign-psbt.js +0 -17
- package/dist/src/sdk/accounts/utils/sign-psbt.js.map +0 -1
- package/dist/src/sdk/actions/kontor/wallet/sign-commit.js +0 -34
- package/dist/src/sdk/actions/kontor/wallet/sign-commit.js.map +0 -1
- package/dist/src/sdk/actions/public/send-raw-transaction.js +0 -7
- package/dist/src/sdk/actions/public/send-raw-transaction.js.map +0 -1
- package/dist/src/sdk/actions/public/test-mempool-accept.js +0 -44
- package/dist/src/sdk/actions/public/test-mempool-accept.js.map +0 -1
- package/dist/src/sdk/chains/definitions/index.js +0 -2
- package/dist/src/sdk/chains/definitions/index.js.map +0 -1
- package/dist/src/sdk/chains/definitions/signet.js +0 -36
- package/dist/src/sdk/chains/definitions/signet.js.map +0 -1
- package/dist/src/sdk/clients/base/create-rpc-client.test.js +0 -145
- package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +0 -1
- package/dist/src/sdk/clients/create-public-client.test.js +0 -113
- package/dist/src/sdk/clients/create-public-client.test.js.map +0 -1
- package/dist/src/sdk/clients/decorators/kontor/wallet.js +0 -13
- package/dist/src/sdk/clients/decorators/kontor/wallet.js.map +0 -1
- package/dist/src/sdk/clients/decorators/public.js +0 -7
- package/dist/src/sdk/clients/decorators/public.js.map +0 -1
- package/dist/src/sdk/clients/decorators/wallet.js +0 -9
- package/dist/src/sdk/clients/decorators/wallet.js.map +0 -1
- package/dist/src/sdk/clients/kontor/create-public-client.test.js +0 -44
- package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +0 -1
- package/dist/src/sdk/clients/kontor/create-wallet-client.js +0 -14
- package/dist/src/sdk/clients/kontor/create-wallet-client.js.map +0 -1
- package/dist/src/sdk/clients/transports/create-http-transport.js +0 -25
- package/dist/src/sdk/clients/transports/create-http-transport.js.map +0 -1
- package/dist/src/sdk/clients/transports/create-rpc-transport.test.js +0 -58
- package/dist/src/sdk/clients/transports/create-rpc-transport.test.js.map +0 -1
- package/dist/src/sdk/clients/transports/custom.js +0 -14
- package/dist/src/sdk/clients/transports/custom.js.map +0 -1
- package/dist/src/sdk/clients/transports/http-rpc.js +0 -84
- package/dist/src/sdk/clients/transports/http-rpc.js.map +0 -1
- package/dist/src/sdk/clients/transports/http-rpc.test.js +0 -147
- package/dist/src/sdk/clients/transports/http-rpc.test.js.map +0 -1
- package/dist/src/sdk/clients/transports/http.js +0 -45
- package/dist/src/sdk/clients/transports/http.js.map +0 -1
- package/dist/src/sdk/contracts/wits.js +0 -26
- package/dist/src/sdk/contracts/wits.js.map +0 -1
- package/dist/src/sdk/errors/address.js +0 -13
- package/dist/src/sdk/errors/address.js.map +0 -1
- package/dist/src/sdk/errors/base.js +0 -92
- package/dist/src/sdk/errors/base.js.map +0 -1
- package/dist/src/sdk/errors/request.js +0 -100
- package/dist/src/sdk/errors/request.js.map +0 -1
- package/dist/src/sdk/errors/rpc.js +0 -30
- package/dist/src/sdk/errors/rpc.js.map +0 -1
- package/dist/src/sdk/errors/transport.js +0 -10
- package/dist/src/sdk/errors/transport.js.map +0 -1
- package/dist/src/sdk/errors/utils.js +0 -2
- package/dist/src/sdk/errors/utils.js.map +0 -1
- package/dist/src/sdk/errors/version.js +0 -2
- package/dist/src/sdk/errors/version.js.map +0 -1
- package/dist/src/sdk/errors/wit.js +0 -19
- package/dist/src/sdk/errors/wit.js.map +0 -1
- package/dist/src/sdk/test/e2e.test.js +0 -75
- package/dist/src/sdk/test/e2e.test.js.map +0 -1
- package/dist/src/sdk/types/account.js +0 -2
- package/dist/src/sdk/types/account.js.map +0 -1
- package/dist/src/sdk/types/btc-rpc.js +0 -2
- package/dist/src/sdk/types/btc-rpc.js.map +0 -1
- package/dist/src/sdk/types/contract.test-d.js +0 -35
- package/dist/src/sdk/types/contract.test-d.js.map +0 -1
- package/dist/src/sdk/types/http-schema.test-d.js +0 -133
- package/dist/src/sdk/types/http-schema.test-d.js.map +0 -1
- package/dist/src/sdk/types/misc.js +0 -2
- package/dist/src/sdk/types/misc.js.map +0 -1
- package/dist/src/sdk/types/rpc.js +0 -19
- package/dist/src/sdk/types/rpc.js.map +0 -1
- package/dist/src/sdk/types/utils.js +0 -2
- package/dist/src/sdk/types/utils.js.map +0 -1
- package/dist/src/sdk/types/wbip001.js +0 -3
- package/dist/src/sdk/types/wbip001.js.map +0 -1
- package/dist/src/sdk/utils/build-http-request.js +0 -55
- package/dist/src/sdk/utils/build-http-request.js.map +0 -1
- package/dist/src/sdk/utils/build-request.js +0 -35
- package/dist/src/sdk/utils/build-request.js.map +0 -1
- package/dist/src/sdk/utils/build-rpc-request.js +0 -84
- package/dist/src/sdk/utils/build-rpc-request.js.map +0 -1
- package/dist/src/sdk/utils/encoding/to-hex.js +0 -23
- package/dist/src/sdk/utils/encoding/to-hex.js.map +0 -1
- package/dist/src/sdk/utils/get-action.js +0 -27
- package/dist/src/sdk/utils/get-action.js.map +0 -1
- package/dist/src/sdk/utils/http.js +0 -137
- package/dist/src/sdk/utils/http.js.map +0 -1
- package/dist/src/sdk/utils/lru.js +0 -35
- package/dist/src/sdk/utils/lru.js.map +0 -1
- package/dist/src/sdk/utils/promise/create-batch-scheduler.js +0 -49
- package/dist/src/sdk/utils/promise/create-batch-scheduler.js.map +0 -1
- package/dist/src/sdk/utils/promise/with-dedupe.js +0 -14
- package/dist/src/sdk/utils/promise/with-dedupe.js.map +0 -1
- package/dist/src/sdk/utils/promise/with-resolvers.js +0 -10
- package/dist/src/sdk/utils/promise/with-resolvers.js.map +0 -1
- package/dist/src/sdk/utils/promise/with-retry.js +0 -25
- package/dist/src/sdk/utils/promise/with-retry.js.map +0 -1
- package/dist/src/sdk/utils/promise/with-timeout.js +0 -30
- package/dist/src/sdk/utils/promise/with-timeout.js.map +0 -1
- package/dist/src/sdk/utils/rpc/http.js +0 -86
- package/dist/src/sdk/utils/rpc/http.js.map +0 -1
- package/dist/src/sdk/utils/rpc/id.js +0 -13
- package/dist/src/sdk/utils/rpc/id.js.map +0 -1
- package/dist/src/sdk/utils/stringify.js +0 -5
- package/dist/src/sdk/utils/stringify.js.map +0 -1
- package/dist/src/sdk/utils/uid.js +0 -14
- package/dist/src/sdk/utils/uid.js.map +0 -1
- package/dist/src/sdk/utils/wait.js +0 -4
- package/dist/src/sdk/utils/wait.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/decimal.js +0 -165
- package/dist/src/sdk/utils/wit/codecs/decimal.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/enum.js +0 -104
- package/dist/src/sdk/utils/wit/codecs/enum.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/integer.js +0 -167
- package/dist/src/sdk/utils/wit/codecs/integer.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/list.js +0 -117
- package/dist/src/sdk/utils/wit/codecs/list.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/option.js +0 -91
- package/dist/src/sdk/utils/wit/codecs/option.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/string.js +0 -27
- package/dist/src/sdk/utils/wit/codecs/string.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/types.js +0 -45
- package/dist/src/sdk/utils/wit/codecs/types.js.map +0 -1
- package/dist/src/sdk/utils/wit/codecs/unit.js +0 -22
- package/dist/src/sdk/utils/wit/codecs/unit.js.map +0 -1
- package/dist/src/sdk/utils/wit/decode-function-result.js +0 -36
- package/dist/src/sdk/utils/wit/decode-function-result.js.map +0 -1
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js +0 -286
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +0 -1
- package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js +0 -75
- package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-function-data.js +0 -17
- package/dist/src/sdk/utils/wit/encode-function-data.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +0 -21
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-function-data.test.js +0 -91
- package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js +0 -250
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js +0 -62
- package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js.map +0 -1
- package/dist/src/sdk/utils/wit/get-wit-item.js +0 -15
- package/dist/src/sdk/utils/wit/get-wit-item.js.map +0 -1
- package/dist/src/sdk/utils/wit/get-wit-item.test.js +0 -118
- package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +0 -1
- package/dist/src/sdk/utils/wit/prepare-encode-function-data.js +0 -24
- package/dist/src/sdk/utils/wit/prepare-encode-function-data.js.map +0 -1
- package/dist/src/wit/error.js +0 -59
- package/dist/src/wit/error.js.map +0 -1
- package/dist/src/wit/narrow.js +0 -14
- package/dist/src/wit/narrow.js.map +0 -1
- package/dist/src/wit/regex.js +0 -6
- package/dist/src/wit/regex.js.map +0 -1
- package/dist/src/wit/register.js +0 -2
- package/dist/src/wit/register.js.map +0 -1
- package/dist/src/wit/type-utils.js +0 -2
- package/dist/src/wit/type-utils.js.map +0 -1
- package/dist/src/wit/utils.js +0 -2
- package/dist/src/wit/utils.js.map +0 -1
- package/dist/src/wit/utils.test-d.js +0 -16
- package/dist/src/wit/utils.test-d.js.map +0 -1
- package/dist/src/wit/version.js +0 -2
- package/dist/src/wit/version.js.map +0 -1
- package/dist/src/wit/wit-parser/core/errors/signature.js +0 -42
- package/dist/src/wit/wit-parser/core/errors/signature.js.map +0 -1
- package/dist/src/wit/wit-parser/core/errors/splitParameters.js +0 -18
- package/dist/src/wit/wit-parser/core/errors/splitParameters.js.map +0 -1
- package/dist/src/wit/wit-parser/core/errors/wit-parameter.js +0 -29
- package/dist/src/wit/wit-parser/core/errors/wit-parameter.js.map +0 -1
- package/dist/src/wit/wit-parser/core/records.js +0 -73
- package/dist/src/wit/wit-parser/core/records.js.map +0 -1
- package/dist/src/wit/wit-parser/core/records.test.js +0 -53
- package/dist/src/wit/wit-parser/core/records.test.js.map +0 -1
- package/dist/src/wit/wit-parser/core/signatures.js +0 -32
- package/dist/src/wit/wit-parser/core/signatures.js.map +0 -1
- package/dist/src/wit/wit-parser/core/signatures.test.js +0 -54
- package/dist/src/wit/wit-parser/core/signatures.test.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/records.js +0 -2
- package/dist/src/wit/wit-parser/core/types/records.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/records.test-d.js +0 -19
- package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/signatures.js +0 -3
- package/dist/src/wit/wit-parser/core/types/signatures.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/signatures.test-d.js +0 -18
- package/dist/src/wit/wit-parser/core/types/signatures.test-d.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/utils.js +0 -2
- package/dist/src/wit/wit-parser/core/types/utils.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js +0 -138
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +0 -1
- package/dist/src/wit/wit-parser/core/utils.js +0 -212
- package/dist/src/wit/wit-parser/core/utils.js.map +0 -1
- package/dist/src/wit/wit-parser/core/utils.test.js +0 -302
- package/dist/src/wit/wit-parser/core/utils.test.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit-parameter.js +0 -26
- package/dist/src/wit/wit-parser/parse-wit-parameter.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +0 -77
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit.js +0 -16
- package/dist/src/wit/wit-parser/parse-wit.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit.test.js +0 -78
- package/dist/src/wit/wit-parser/parse-wit.test.js.map +0 -1
- package/dist/src/wit/wit.js +0 -2
- package/dist/src/wit/wit.js.map +0 -1
- package/dist/src/wit/wit.test.js +0 -6
- package/dist/src/wit/wit.test.js.map +0 -1
- package/dist/test/globalSetup.js +0 -14
- package/dist/test/globalSetup.js.map +0 -1
- package/dist/test/src/wits.js +0 -21
- package/dist/test/src/wits.js.map +0 -1
|
@@ -19,22 +19,22 @@ import {
|
|
|
19
19
|
} from "../../../actions/kontor/public/call-view.js";
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
type
|
|
24
|
-
type
|
|
25
|
-
} from "../../../actions/kontor/public/call-
|
|
22
|
+
callCompose,
|
|
23
|
+
type CallComposeParameters,
|
|
24
|
+
type CallComposeReturnType,
|
|
25
|
+
} from "../../../actions/kontor/public/call-compose.js";
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
} from "../../../actions/kontor/public/build-instruction.js";
|
|
28
|
+
buildInstructionQuery,
|
|
29
|
+
type BuildInstructionQueryParameters,
|
|
30
|
+
type BuildInstructionQueryReturnType,
|
|
31
|
+
} from "../../../actions/kontor/public/build-instruction-query.js";
|
|
32
32
|
|
|
33
33
|
import {
|
|
34
|
-
|
|
35
|
-
type
|
|
36
|
-
type
|
|
37
|
-
} from "../../../actions/kontor/public/build-compose-
|
|
34
|
+
buildComposeQuery,
|
|
35
|
+
type BuildComposeQueryParameters,
|
|
36
|
+
type BuildComposeQueryReturnType,
|
|
37
|
+
} from "../../../actions/kontor/public/build-compose-query.js";
|
|
38
38
|
|
|
39
39
|
import {
|
|
40
40
|
inspect,
|
|
@@ -75,17 +75,17 @@ export type KontorPublicActions<
|
|
|
75
75
|
args: CallViewParameters<chain>,
|
|
76
76
|
) => Promise<CallViewReturnType>;
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
args:
|
|
80
|
-
) => Promise<
|
|
78
|
+
buildInstructionQuery: <chain extends Chain | undefined>(
|
|
79
|
+
args: BuildInstructionQueryParameters<chain>,
|
|
80
|
+
) => Promise<BuildInstructionQueryReturnType>;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
args:
|
|
84
|
-
) => Promise<
|
|
82
|
+
buildComposeQuery: <chain extends Chain | undefined>(
|
|
83
|
+
args: BuildComposeQueryParameters<chain>,
|
|
84
|
+
) => Promise<BuildComposeQueryReturnType>;
|
|
85
85
|
|
|
86
86
|
callProc: <chain extends Chain | undefined>(
|
|
87
|
-
args:
|
|
88
|
-
) => Promise<
|
|
87
|
+
args: CallComposeParameters<chain>,
|
|
88
|
+
) => Promise<CallComposeReturnType>;
|
|
89
89
|
inspect: <_chain extends Chain | undefined>(
|
|
90
90
|
args: InspectParameters,
|
|
91
91
|
) => Promise<InspectReturnType>;
|
|
@@ -102,9 +102,9 @@ export function kontorPublicActions<
|
|
|
102
102
|
viewContract: (args) => viewContract(client, args),
|
|
103
103
|
procContract: (args) => procContract(client, args),
|
|
104
104
|
callView: (args) => callView(client, args),
|
|
105
|
-
callProc: (args) =>
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
callProc: (args) => callCompose(client, args),
|
|
106
|
+
buildInstructionQuery: (args) => buildInstructionQuery(client, args),
|
|
107
|
+
buildComposeQuery: (args) => buildComposeQuery(client, args),
|
|
108
108
|
inspect: (args) => inspect(client, args),
|
|
109
109
|
};
|
|
110
110
|
}
|
|
@@ -8,6 +8,13 @@ import {
|
|
|
8
8
|
type SendRawTransactionReturnType,
|
|
9
9
|
sendRawTransaction,
|
|
10
10
|
} from "../../actions/public/send-raw-transaction.js";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type TestMempoolAcceptParams,
|
|
14
|
+
type TestMempoolAcceptReturnType,
|
|
15
|
+
testMempoolAccept,
|
|
16
|
+
} from "../../actions/public/test-mempool-accept.js";
|
|
17
|
+
|
|
11
18
|
import type { PublicClient as PublicClient } from "../create-public-client.js";
|
|
12
19
|
|
|
13
20
|
export type PublicActions<
|
|
@@ -20,6 +27,9 @@ export type PublicActions<
|
|
|
20
27
|
sendRawTransaction: (
|
|
21
28
|
parameters: SendRawTransactionParams,
|
|
22
29
|
) => Promise<SendRawTransactionReturnType>;
|
|
30
|
+
testMempoolAccept: (
|
|
31
|
+
parameters: TestMempoolAcceptParams,
|
|
32
|
+
) => Promise<TestMempoolAcceptReturnType>;
|
|
23
33
|
};
|
|
24
34
|
|
|
25
35
|
export function publicActions<
|
|
@@ -31,5 +41,6 @@ export function publicActions<
|
|
|
31
41
|
): PublicActions<chain, account> {
|
|
32
42
|
return {
|
|
33
43
|
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
|
44
|
+
testMempoolAccept: (args) => testMempoolAccept(client, args),
|
|
34
45
|
};
|
|
35
46
|
}
|
package/src/sdk/test/e2e.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { createPublicClient as createKontorPublicClient } from "../clients/konto
|
|
|
5
5
|
import { http } from "../clients/transports/http.js";
|
|
6
6
|
import { mnemonicToAccount } from "../accounts/mnemonic-to-account.js";
|
|
7
7
|
import { createWalletClient as createKontorWalletClient } from "../clients/kontor/create-wallet-client.js";
|
|
8
|
+
|
|
8
9
|
import { custom } from "../clients/transports/custom.js";
|
|
9
10
|
import { Transaction } from "@scure/btc-signer";
|
|
10
11
|
import { hex } from "@scure/base";
|
|
@@ -32,12 +33,168 @@ export const nativeTokenRaw = [
|
|
|
32
33
|
|
|
33
34
|
export const wit = parseWit(nativeTokenRaw);
|
|
34
35
|
|
|
36
|
+
// test("e2e kontor wallet client", async () => {
|
|
37
|
+
// const account = mnemonicToAccount(process.env.TEST_MNEMONIC!);
|
|
38
|
+
//
|
|
39
|
+
// const kontorPublicClient = createKontorPublicClient({
|
|
40
|
+
// transport: http("https://signet-staging.kontor.network:35000/api"),
|
|
41
|
+
// account,
|
|
42
|
+
// chain: signet,
|
|
43
|
+
// });
|
|
44
|
+
//
|
|
45
|
+
// const kontorWalletClient = createKontorWalletClient({
|
|
46
|
+
// account,
|
|
47
|
+
// // TODO: transport is not used for local account.
|
|
48
|
+
// transport: custom({
|
|
49
|
+
// request: async (_args: any) => null,
|
|
50
|
+
// }),
|
|
51
|
+
// });
|
|
52
|
+
//
|
|
53
|
+
// const res = await kontorPublicClient.procContract({
|
|
54
|
+
// wit: wit,
|
|
55
|
+
// // TODO: add optional account override
|
|
56
|
+
//
|
|
57
|
+
// functionName: "mint", // functin name is only valid if it's got a proc-context
|
|
58
|
+
// contractAddress: "token_0_0",
|
|
59
|
+
// args: [[7n, 18]],
|
|
60
|
+
// satsPerVByte: 1,
|
|
61
|
+
// utxos: [
|
|
62
|
+
// "641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
63
|
+
// ],
|
|
64
|
+
// gas: 10n,
|
|
65
|
+
// });
|
|
66
|
+
//
|
|
67
|
+
// const commit: Transaction = await kontorWalletClient.signCommit({
|
|
68
|
+
// account: account,
|
|
69
|
+
// chain: signet,
|
|
70
|
+
// psbt: res.result.commit_psbt_hex,
|
|
71
|
+
// });
|
|
72
|
+
//
|
|
73
|
+
// const reveal: Transaction = await kontorWalletClient.signReveal({
|
|
74
|
+
// account: account,
|
|
75
|
+
// chain: signet,
|
|
76
|
+
// psbt: res.result.reveal_psbt_hex,
|
|
77
|
+
// parcipantScripts: res.result.per_participant,
|
|
78
|
+
// });
|
|
79
|
+
//
|
|
80
|
+
// const commitExtracted = commit.extract();
|
|
81
|
+
// const revealExtracted = reveal.extract();
|
|
82
|
+
//
|
|
83
|
+
// // const m = await btcPublicClient.testMempoolAccept({
|
|
84
|
+
// // rawtx: [hex.encode(commitExtracted), hex.encode(revealExtracted)],
|
|
85
|
+
// // options: {},
|
|
86
|
+
// // });
|
|
87
|
+
// //
|
|
88
|
+
//
|
|
89
|
+
// const r = await fetch("https://signet.kontor.network:38332", {
|
|
90
|
+
// method: "POST",
|
|
91
|
+
// headers: {
|
|
92
|
+
// "Content-Type": "application/json",
|
|
93
|
+
// Authorization: `Basic ${Buffer.from("rpc:rpc").toString("base64")}`,
|
|
94
|
+
// },
|
|
95
|
+
// body: JSON.stringify({
|
|
96
|
+
// method: "testmempoolaccept",
|
|
97
|
+
// params: [[hex.encode(commitExtracted), hex.encode(revealExtracted)]],
|
|
98
|
+
// }),
|
|
99
|
+
// });
|
|
100
|
+
// console.log({
|
|
101
|
+
// r,
|
|
102
|
+
// reveal: [hex.encode(commitExtracted), hex.encode(revealExtracted)],
|
|
103
|
+
// });
|
|
104
|
+
//
|
|
105
|
+
// const j = await r.json();
|
|
106
|
+
//
|
|
107
|
+
// console.log(j);
|
|
108
|
+
// //
|
|
109
|
+
// // const op = await kontorPublicClient.inspect({
|
|
110
|
+
// // hex: hex.encode(revealExtracted),
|
|
111
|
+
// // });
|
|
112
|
+
//
|
|
113
|
+
// // console.log(JSON.stringify(op.result[0]!.op));
|
|
114
|
+
// //
|
|
115
|
+
// });
|
|
116
|
+
|
|
35
117
|
test("e2e kontor wallet client", async () => {
|
|
36
118
|
const account = mnemonicToAccount(process.env.TEST_MNEMONIC!);
|
|
37
119
|
|
|
120
|
+
const res = {
|
|
121
|
+
result: {
|
|
122
|
+
commit_transaction: {
|
|
123
|
+
version: 2,
|
|
124
|
+
lock_time: 0,
|
|
125
|
+
input: [
|
|
126
|
+
{
|
|
127
|
+
previous_output:
|
|
128
|
+
"641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
129
|
+
script_sig: "",
|
|
130
|
+
sequence: 4294967295,
|
|
131
|
+
witness: [],
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
output: [
|
|
135
|
+
{
|
|
136
|
+
value: 570,
|
|
137
|
+
script_pubkey:
|
|
138
|
+
"51207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: 8502,
|
|
142
|
+
script_pubkey:
|
|
143
|
+
"5120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f",
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
commit_transaction_hex:
|
|
148
|
+
"0200000001332a0e2d0c369ebb984ce8addb4387bd6702f59b255ceada1c0fcff4ed401c640100000000ffffffff023a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f3621000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f00000000",
|
|
149
|
+
commit_psbt_hex:
|
|
150
|
+
"70736274ff0100890200000001332a0e2d0c369ebb984ce8addb4387bd6702f59b255ceada1c0fcff4ed401c640100000000ffffffff023a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f3621000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f000000000001012b8e24000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f0117202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f000000",
|
|
151
|
+
reveal_transaction: {
|
|
152
|
+
version: 2,
|
|
153
|
+
lock_time: 0,
|
|
154
|
+
input: [
|
|
155
|
+
{
|
|
156
|
+
previous_output:
|
|
157
|
+
"4b195fabb3bd5360de2e2db6821df9d8909f0dbd5f1ba50ae1ca71a841080c3d:0",
|
|
158
|
+
script_sig: "",
|
|
159
|
+
sequence: 4294967295,
|
|
160
|
+
witness: [],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
output: [
|
|
164
|
+
{
|
|
165
|
+
value: 330,
|
|
166
|
+
script_pubkey:
|
|
167
|
+
"5120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
reveal_transaction_hex:
|
|
172
|
+
"02000000013d0c0841a871cae10aa51b5fbd0d9f90d8f91d82b62d2ede6053bdb3ab5f194b0000000000ffffffff014a01000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f00000000",
|
|
173
|
+
reveal_psbt_hex:
|
|
174
|
+
"70736274ff01005e02000000013d0c0841a871cae10aa51b5fbd0d9f90d8f91d82b62d2ede6053bdb3ab5f194b0000000000ffffffff014a01000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f000000000001012b3a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f0117202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f0000",
|
|
175
|
+
per_participant: [
|
|
176
|
+
{
|
|
177
|
+
address:
|
|
178
|
+
"tb1pj2wrjsg0ksmmflec0myf3j7qnqm9myvk2pesqn7y8cqn6sgdg9ls9u6tar",
|
|
179
|
+
x_only_public_key:
|
|
180
|
+
"2c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f",
|
|
181
|
+
commit_tap_leaf_script: {
|
|
182
|
+
leafVersion: 192,
|
|
183
|
+
script:
|
|
184
|
+
"202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51fac0063036b6f6e00010268",
|
|
185
|
+
controlBlock:
|
|
186
|
+
"c12c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f",
|
|
187
|
+
},
|
|
188
|
+
chained_tap_leaf_script: null,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
38
194
|
const kontorPublicClient = createKontorPublicClient({
|
|
39
195
|
transport: http("https://signet-staging.kontor.network:35000/api"),
|
|
40
196
|
account,
|
|
197
|
+
chain: signet,
|
|
41
198
|
});
|
|
42
199
|
|
|
43
200
|
const kontorWalletClient = createKontorWalletClient({
|
|
@@ -48,22 +205,21 @@ test("e2e kontor wallet client", async () => {
|
|
|
48
205
|
}),
|
|
49
206
|
});
|
|
50
207
|
|
|
51
|
-
const res = await kontorPublicClient.procContract({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
208
|
+
// const res = await kontorPublicClient.procContract({
|
|
209
|
+
// wit: wit,
|
|
210
|
+
// // TODO: add optional account override
|
|
211
|
+
//
|
|
212
|
+
// functionName: "mint", // functin name is only valid if it's got a proc-context
|
|
213
|
+
// contractAddress: "token_0_0",
|
|
214
|
+
// args: [[7n, 18]],
|
|
215
|
+
// satsPerVByte: 1,
|
|
216
|
+
// utxos: [
|
|
217
|
+
// "641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
218
|
+
// ],
|
|
219
|
+
// gas: 10n,
|
|
220
|
+
// });
|
|
64
221
|
|
|
65
|
-
|
|
66
|
-
const commit_: Transaction = await kontorWalletClient.signCommit({
|
|
222
|
+
const commit: Transaction = await kontorWalletClient.signCommit({
|
|
67
223
|
account: account,
|
|
68
224
|
chain: signet,
|
|
69
225
|
psbt: res.result.commit_psbt_hex,
|
|
@@ -76,8 +232,30 @@ test("e2e kontor wallet client", async () => {
|
|
|
76
232
|
parcipantScripts: res.result.per_participant,
|
|
77
233
|
});
|
|
78
234
|
|
|
235
|
+
const commitExtracted = commit.extract();
|
|
79
236
|
const revealExtracted = reveal.extract();
|
|
80
237
|
|
|
238
|
+
// const m = await btcPublicClient.testMempoolAccept({
|
|
239
|
+
// rawtx: [hex.encode(commitExtracted), hex.encode(revealExtracted)],
|
|
240
|
+
// options: {},
|
|
241
|
+
// });
|
|
242
|
+
|
|
243
|
+
const r = await fetch("https://signet.kontor.network:38332", {
|
|
244
|
+
method: "POST",
|
|
245
|
+
headers: {
|
|
246
|
+
"Content-Type": "application/json",
|
|
247
|
+
Authorization: `Basic ${Buffer.from("rpc:rpc").toString("base64")}`,
|
|
248
|
+
},
|
|
249
|
+
body: JSON.stringify({
|
|
250
|
+
method: "testmempoolaccept",
|
|
251
|
+
params: [[hex.encode(commitExtracted), hex.encode(revealExtracted)]],
|
|
252
|
+
}),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const mempoolAccept = await r.json();
|
|
256
|
+
|
|
257
|
+
console.log({ mempoolAccept: mempoolAccept.result });
|
|
258
|
+
//
|
|
81
259
|
const op = await kontorPublicClient.inspect({
|
|
82
260
|
hex: hex.encode(revealExtracted),
|
|
83
261
|
});
|
package/src/sdk/types/btc-rpc.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Prettify } from "../../wit/type-utils.js";
|
|
2
2
|
|
|
3
|
-
// import type {
|
|
4
|
-
// TestMempoolAcceptParams,
|
|
5
|
-
// TestMempoolAcceptReturnType,
|
|
6
|
-
// } from "../actions/public/test-mempool-accept.js";
|
|
7
|
-
|
|
8
3
|
import type { RpcRequestFn, RpcSchema, RpcSchemaEntry } from "./rpc-schema.js";
|
|
9
4
|
|
|
10
5
|
export type SendRawTransactionParams = [
|
|
@@ -16,18 +11,24 @@ export interface SendRawTransactionReturnType {
|
|
|
16
11
|
txid: string;
|
|
17
12
|
}
|
|
18
13
|
|
|
14
|
+
export type TestMempoolAcceptParams = [
|
|
15
|
+
txs: string[],
|
|
16
|
+
opts?: { maxFeeRate: number | string },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export type TestMempoolAcceptReturnType = any;
|
|
20
|
+
|
|
19
21
|
export type BtcRpcSchema = readonly [
|
|
20
22
|
RpcSchemaEntry<
|
|
21
23
|
"sendrawtransaction",
|
|
22
24
|
SendRawTransactionParams,
|
|
23
25
|
SendRawTransactionReturnType
|
|
24
26
|
>,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// >,
|
|
27
|
+
RpcSchemaEntry<
|
|
28
|
+
"testmempoolaccept",
|
|
29
|
+
TestMempoolAcceptParams,
|
|
30
|
+
TestMempoolAcceptReturnType
|
|
31
|
+
>,
|
|
31
32
|
];
|
|
32
33
|
|
|
33
34
|
export type BtcNodeRequestFn<
|
package/src/sdk/types/kontor.ts
CHANGED
|
@@ -7,8 +7,10 @@ import type {
|
|
|
7
7
|
OpWithResult as OpWithResult_,
|
|
8
8
|
ViewResult as ViewResult_,
|
|
9
9
|
InstructionQuery as InstructionQuery_,
|
|
10
|
+
Inst as Inst_,
|
|
10
11
|
ParticipantScripts as ParticipantScripts_,
|
|
11
12
|
} from "@kontor/kontor-ts";
|
|
13
|
+
|
|
12
14
|
import type { ResolvedRegister } from "../../wit/register.js";
|
|
13
15
|
|
|
14
16
|
import type { HttpSchemaEntry, HttpParameters } from "./http-schema.js";
|
|
@@ -31,6 +33,42 @@ export type InstructionQuery = InstructionQuery_;
|
|
|
31
33
|
|
|
32
34
|
export type ParticipantScripts = ParticipantScripts_;
|
|
33
35
|
|
|
36
|
+
export type Inst = Inst_;
|
|
37
|
+
|
|
38
|
+
export namespace Instruction {
|
|
39
|
+
export function publish(params: {
|
|
40
|
+
name: string;
|
|
41
|
+
bytes: number[]; // or Uint8Array
|
|
42
|
+
gasLimit: bigint;
|
|
43
|
+
}): Inst {
|
|
44
|
+
return {
|
|
45
|
+
Publish: {
|
|
46
|
+
gas_limit: Number(params.gasLimit),
|
|
47
|
+
name: params.name,
|
|
48
|
+
bytes: params.bytes,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function call(params: {
|
|
54
|
+
contract: ResolvedRegister["contractAddress"]; // stricter than plain string if you want
|
|
55
|
+
expr: string;
|
|
56
|
+
gasLimit: bigint;
|
|
57
|
+
}): Inst {
|
|
58
|
+
return {
|
|
59
|
+
Call: {
|
|
60
|
+
gas_limit: Number(params.gasLimit),
|
|
61
|
+
contract: params.contract,
|
|
62
|
+
expr: params.expr,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function issuance(): Inst {
|
|
68
|
+
return "Issuance";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
34
72
|
export type KontorSchemaPublic = readonly [
|
|
35
73
|
HttpSchemaEntry<
|
|
36
74
|
"/contracts/:contractAddress",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../src/exports/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACjB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;GAIlD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { toHex } from "../utils/encoding/to-hex.js";
|
|
2
|
-
import { privateKeyToAccount, } from "./private-key-to-account.js";
|
|
3
|
-
/**
|
|
4
|
-
* @description Creates an Account from a HD Key.
|
|
5
|
-
*
|
|
6
|
-
* @returns A HD Account.
|
|
7
|
-
*/
|
|
8
|
-
export function hdKeyToAccount(hdKey_, { coinType = 0, // 0 = mainnet, 1 =
|
|
9
|
-
accountIndex = 0, addressIndex = 0, changeIndex = 0, path, ...options } = {}) {
|
|
10
|
-
// https://bips.dev/86/
|
|
11
|
-
const hdKey = hdKey_.derive(path ||
|
|
12
|
-
`m/86'/${coinType}'/${accountIndex}'/${changeIndex}/${addressIndex}`);
|
|
13
|
-
const account = privateKeyToAccount(toHex(hdKey.privateKey), options);
|
|
14
|
-
return {
|
|
15
|
-
...account,
|
|
16
|
-
getHdKey: () => hdKey,
|
|
17
|
-
source: "hd",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=hd-key-to-account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hd-key-to-account.js","sourceRoot":"","sources":["../../../../src/sdk/accounts/hd-key-to-account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAGL,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAWrC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAa,EACb,EACE,QAAQ,GAAG,CAAC,EAAE,mBAAmB;AACjC,YAAY,GAAG,CAAC,EAChB,YAAY,GAAG,CAAC,EAChB,WAAW,GAAG,CAAC,EACf,IAAI,EACJ,GAAG,OAAO,KACe,EAAE;IAE7B,uBAAuB;IACvB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,IAAI;QACF,SAAS,QAAQ,KAAK,YAAY,KAAK,WAAW,IAAI,YAAY,EAAE,CACvE,CAAC;IACF,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,UAAW,CAAC,EAAE,OAAO,CAAC,CAAC;IACvE,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { HDKey } from "@scure/bip32";
|
|
2
|
-
import { mnemonicToSeedSync } from "@scure/bip39";
|
|
3
|
-
import { hdKeyToAccount, } from "./hd-key-to-account.js";
|
|
4
|
-
/**
|
|
5
|
-
* @description Creates an Account from a mnemonic phrase.
|
|
6
|
-
*
|
|
7
|
-
* @returns A HD Account.
|
|
8
|
-
*/
|
|
9
|
-
export function mnemonicToAccount(mnemonic, _opts = {}) {
|
|
10
|
-
const seed = mnemonicToSeedSync(mnemonic);
|
|
11
|
-
return hdKeyToAccount(HDKey.fromMasterSeed(seed), {
|
|
12
|
-
// TODO: this should not be hardcoded
|
|
13
|
-
coinType: 1,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=mnemonic-to-account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonic-to-account.js","sourceRoot":"","sources":["../../../../src/sdk/accounts/mnemonic-to-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAGL,cAAc,GACf,MAAM,wBAAwB,CAAC;AAOhC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,QAAkC,EAAE;IAEpC,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;QAChD,qCAAqC;QACrC,QAAQ,EAAE,CAAC;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { mnemonicToAccount } from "./mnemonic-to-account.js";
|
|
3
|
-
const mnemonic = "test test test test test test test test test test test junk";
|
|
4
|
-
// TODO: should take a network argument
|
|
5
|
-
test("default", () => {
|
|
6
|
-
expect(mnemonicToAccount(mnemonic)).toMatchInlineSnapshot(`
|
|
7
|
-
{
|
|
8
|
-
"address": "tb1pfewlxm8meyyvgjydfu7v8j4ej64symj6ut8sf66h9germp94qgzsgnnjhk",
|
|
9
|
-
"getHdKey": [Function],
|
|
10
|
-
"signMessage": [Function],
|
|
11
|
-
"signPsbt": [Function],
|
|
12
|
-
"source": "hd",
|
|
13
|
-
"type": "local",
|
|
14
|
-
"xOnlyPubKey": "8c7fc6552af4384a13791e63bac79ff2bcfeedf143a88d6dc4b6080a8829cdc1",
|
|
15
|
-
}
|
|
16
|
-
`);
|
|
17
|
-
});
|
|
18
|
-
// describe('args: addressIndex', () => {
|
|
19
|
-
// Array.from({ length: 10 }).forEach((_, index) => {
|
|
20
|
-
// test(`addressIndex: ${index}`, () => {
|
|
21
|
-
// const account = mnemonicToAccount(mnemonic, {
|
|
22
|
-
// addressIndex: index,
|
|
23
|
-
// })
|
|
24
|
-
// expect(account.address).toEqual(getAddress(accounts[index].address))
|
|
25
|
-
// })
|
|
26
|
-
// })
|
|
27
|
-
// })
|
|
28
|
-
//
|
|
29
|
-
// describe('args: path', () => {
|
|
30
|
-
// Array.from({ length: 10 }).forEach((_, index) => {
|
|
31
|
-
// test(`path: m/44'/60'/0'/0/${index}`, () => {
|
|
32
|
-
// const account = mnemonicToAccount(mnemonic, {
|
|
33
|
-
// path: `m/44'/60'/0'/0/${index}`,
|
|
34
|
-
// })
|
|
35
|
-
// expect(account.address).toEqual(getAddress(accounts[index].address))
|
|
36
|
-
// })
|
|
37
|
-
// })
|
|
38
|
-
// })
|
|
39
|
-
//
|
|
40
|
-
// test('args: accountIndex', () => {
|
|
41
|
-
// expect(
|
|
42
|
-
// mnemonicToAccount(mnemonic, { accountIndex: 1 }).address,
|
|
43
|
-
// ).toMatchInlineSnapshot('"0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650"')
|
|
44
|
-
// expect(
|
|
45
|
-
// mnemonicToAccount(mnemonic, { accountIndex: 2 }).address,
|
|
46
|
-
// ).toMatchInlineSnapshot('"0x98e503f35D0a019cB0a251aD243a4cCFCF371F46"')
|
|
47
|
-
// expect(
|
|
48
|
-
// mnemonicToAccount(mnemonic, { accountIndex: 3 }).address,
|
|
49
|
-
// ).toMatchInlineSnapshot('"0xCB9fA1eA9b8A3bf422a8639f23Df77ea66020eC2"')
|
|
50
|
-
// })
|
|
51
|
-
//
|
|
52
|
-
// test('args: changeIndex', () => {
|
|
53
|
-
// expect(
|
|
54
|
-
// mnemonicToAccount(mnemonic, { changeIndex: 1 }).address,
|
|
55
|
-
// ).toMatchInlineSnapshot('"0x4b39F7b0624b9dB86AD293686bc38B903142dbBc"')
|
|
56
|
-
// expect(
|
|
57
|
-
// mnemonicToAccount(mnemonic, { changeIndex: 2 }).address,
|
|
58
|
-
// ).toMatchInlineSnapshot('"0xe0Ff44FDb999d485DCFe6B0840f0d14EEA8a08A0"')
|
|
59
|
-
// expect(
|
|
60
|
-
// mnemonicToAccount(mnemonic, { changeIndex: 3 }).address,
|
|
61
|
-
// ).toMatchInlineSnapshot('"0x4E0eBc370cAdc5d152505EA4FEbcf839E7E2D3F8"')
|
|
62
|
-
// })
|
|
63
|
-
//
|
|
64
|
-
// test('sign message', async () => {
|
|
65
|
-
// const account = mnemonicToAccount(mnemonic)
|
|
66
|
-
// expect(
|
|
67
|
-
// await account.signMessage({ message: 'hello world' }),
|
|
68
|
-
// ).toMatchInlineSnapshot(
|
|
69
|
-
// '"0xa461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b"',
|
|
70
|
-
// )
|
|
71
|
-
// })
|
|
72
|
-
//
|
|
73
|
-
// test('sign transaction', async () => {
|
|
74
|
-
// const account = mnemonicToAccount(mnemonic)
|
|
75
|
-
// expect(
|
|
76
|
-
// await account.signTransaction({
|
|
77
|
-
// chainId: 1,
|
|
78
|
-
// maxFeePerGas: parseGwei('20'),
|
|
79
|
-
// gas: 21000n,
|
|
80
|
-
// to: accounts[1].address,
|
|
81
|
-
// value: parseEther('1'),
|
|
82
|
-
// }),
|
|
83
|
-
// ).toMatchInlineSnapshot(
|
|
84
|
-
// '"0x02f86f0180808504a817c8008252089470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c001a0f40a2d2ae9638056cafbe9083c7125edc8555e0e715db0984dd859a5c6dfac57a020f36fd0b32bef4d6d75c62f220e59c5fb60c244ca3b361e750985ee5c3a0931"',
|
|
85
|
-
// )
|
|
86
|
-
// })
|
|
87
|
-
//
|
|
88
|
-
// test('sign typed data', async () => {
|
|
89
|
-
// const account = mnemonicToAccount(mnemonic)
|
|
90
|
-
// expect(
|
|
91
|
-
// await account.signTypedData({ ...typedData.basic, primaryType: 'Mail' }),
|
|
92
|
-
// ).toMatchInlineSnapshot(
|
|
93
|
-
// '"0x32f3d5975ba38d6c2fba9b95d5cbed1febaa68003d3d588d51f2de522ad54117760cfc249470a75232552e43991f53953a3d74edf6944553c6bef2469bb9e5921b"',
|
|
94
|
-
// )
|
|
95
|
-
// })
|
|
96
|
-
//# sourceMappingURL=mnemonic-to-account.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonic-to-account.test.js","sourceRoot":"","sources":["../../../../src/sdk/accounts/mnemonic-to-account.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,QAAQ,GAAG,6DAA6D,CAAC;AAE/E,uCAAuC;AACvC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;YAUhD,CAAC,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,yCAAyC;AACzC,uDAAuD;AACvD,6CAA6C;AAC7C,sDAAsD;AACtD,+BAA+B;AAC/B,WAAW;AACX,6EAA6E;AAC7E,SAAS;AACT,OAAO;AACP,KAAK;AACL,EAAE;AACF,iCAAiC;AACjC,uDAAuD;AACvD,oDAAoD;AACpD,sDAAsD;AACtD,2CAA2C;AAC3C,WAAW;AACX,6EAA6E;AAC7E,SAAS;AACT,OAAO;AACP,KAAK;AACL,EAAE;AACF,qCAAqC;AACrC,YAAY;AACZ,gEAAgE;AAChE,4EAA4E;AAC5E,YAAY;AACZ,gEAAgE;AAChE,4EAA4E;AAC5E,YAAY;AACZ,gEAAgE;AAChE,4EAA4E;AAC5E,KAAK;AACL,EAAE;AACF,oCAAoC;AACpC,YAAY;AACZ,+DAA+D;AAC/D,4EAA4E;AAC5E,YAAY;AACZ,+DAA+D;AAC/D,4EAA4E;AAC5E,YAAY;AACZ,+DAA+D;AAC/D,4EAA4E;AAC5E,KAAK;AACL,EAAE;AACF,qCAAqC;AACrC,gDAAgD;AAChD,YAAY;AACZ,6DAA6D;AAC7D,6BAA6B;AAC7B,gJAAgJ;AAChJ,MAAM;AACN,KAAK;AACL,EAAE;AACF,yCAAyC;AACzC,gDAAgD;AAChD,YAAY;AACZ,sCAAsC;AACtC,oBAAoB;AACpB,uCAAuC;AACvC,qBAAqB;AACrB,iCAAiC;AACjC,gCAAgC;AAChC,UAAU;AACV,6BAA6B;AAC7B,kPAAkP;AAClP,MAAM;AACN,KAAK;AACL,EAAE;AACF,wCAAwC;AACxC,gDAAgD;AAChD,YAAY;AACZ,gFAAgF;AAChF,6BAA6B;AAC7B,gJAAgJ;AAChJ,MAAM;AACN,KAAK"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { InvalidAddressError, } from "../errors/address.js";
|
|
2
|
-
const isAddress = (_, __) => true;
|
|
3
|
-
/**
|
|
4
|
-
* @description Creates an Account from a custom signing implementation.
|
|
5
|
-
*
|
|
6
|
-
* @returns A Local Account.
|
|
7
|
-
*/
|
|
8
|
-
export function toLocalAccount(source) {
|
|
9
|
-
if (typeof source === "string") {
|
|
10
|
-
if (!isAddress(source, { strict: false }))
|
|
11
|
-
throw new InvalidAddressError({ address: source });
|
|
12
|
-
return {
|
|
13
|
-
address: source,
|
|
14
|
-
type: "json-rpc",
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (!isAddress(source.address, { strict: false }))
|
|
18
|
-
throw new InvalidAddressError({ address: source.address });
|
|
19
|
-
return {
|
|
20
|
-
address: source.address,
|
|
21
|
-
xOnlyPubKey: source.xOnlyPubKey,
|
|
22
|
-
signMessage: source.signMessage,
|
|
23
|
-
signPsbt: source.signPsbt,
|
|
24
|
-
source: "custom",
|
|
25
|
-
type: "local",
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=to-local-account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-local-account.js","sourceRoot":"","sources":["../../../../src/sdk/accounts/to-local-account.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC;AAW9C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAqB;IAErB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YACvC,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,OAAO;YACL,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,UAAU;SACsB,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC/C,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,OAAO;KACyB,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/sdk/accounts/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-account.js","sourceRoot":"","sources":["../../../../../src/sdk/accounts/utils/parse-account.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,YAAY,CAG1B,OAAyB;IAIzB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACxB,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;YACnB,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YACvB,IAAI,EAAE,UAAU;SACV,CAAC;IACX,OAAO,OAAc,CAAC;AACxB,CAAC"}
|