schemos 0.0.1 → 0.1.1
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/LICENSE +21 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/client.test-d.d.ts +2 -0
- package/dist/client.test-d.d.ts.map +1 -0
- package/dist/client.test-d.js +50 -0
- package/dist/client.test-d.js.map +1 -0
- package/dist/contract.bench-d.d.ts +2 -0
- package/dist/contract.bench-d.d.ts.map +1 -0
- package/dist/contract.bench-d.js +67 -0
- package/dist/contract.bench-d.js.map +1 -0
- package/dist/contract.d.ts +27 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +30 -0
- package/dist/contract.js.map +1 -0
- package/dist/contract.test-d.d.ts +2 -0
- package/dist/contract.test-d.d.ts.map +1 -0
- package/dist/contract.test-d.js +147 -0
- package/dist/contract.test-d.js.map +1 -0
- package/dist/contract.test.d.ts +2 -0
- package/dist/contract.test.d.ts.map +1 -0
- package/dist/contract.test.js +77 -0
- package/dist/contract.test.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/cw20/execute.d.ts +367 -0
- package/dist/schemas/cw20/execute.d.ts.map +1 -0
- package/dist/schemas/cw20/execute.js +398 -0
- package/dist/schemas/cw20/execute.js.map +1 -0
- package/dist/schemas/cw20/index.d.ts +905 -0
- package/dist/schemas/cw20/index.d.ts.map +1 -0
- package/dist/schemas/cw20/index.js +10 -0
- package/dist/schemas/cw20/index.js.map +1 -0
- package/dist/schemas/cw20/query.d.ts +160 -0
- package/dist/schemas/cw20/query.d.ts.map +1 -0
- package/dist/schemas/cw20/query.js +170 -0
- package/dist/schemas/cw20/query.js.map +1 -0
- package/dist/schemas/cw20/responses.d.ts +386 -0
- package/dist/schemas/cw20/responses.d.ts.map +1 -0
- package/dist/schemas/cw20/responses.js +416 -0
- package/dist/schemas/cw20/responses.js.map +1 -0
- package/dist/schemas/cw721/execute.d.ts +543 -0
- package/dist/schemas/cw721/execute.d.ts.map +1 -0
- package/dist/schemas/cw721/execute.js +597 -0
- package/dist/schemas/cw721/execute.js.map +1 -0
- package/dist/schemas/cw721/index.d.ts +2507 -0
- package/dist/schemas/cw721/index.d.ts.map +1 -0
- package/dist/schemas/cw721/index.js +10 -0
- package/dist/schemas/cw721/index.js.map +1 -0
- package/dist/schemas/cw721/query.d.ts +487 -0
- package/dist/schemas/cw721/query.d.ts.map +1 -0
- package/dist/schemas/cw721/query.js +526 -0
- package/dist/schemas/cw721/query.js.map +1 -0
- package/dist/schemas/cw721/responses.d.ts +1485 -0
- package/dist/schemas/cw721/responses.d.ts.map +1 -0
- package/dist/schemas/cw721/responses.js +1675 -0
- package/dist/schemas/cw721/responses.js.map +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/schemas.test-d.d.ts +2 -0
- package/dist/schemas/schemas.test-d.d.ts.map +1 -0
- package/dist/schemas/schemas.test-d.js +92 -0
- package/dist/schemas/schemas.test-d.js.map +1 -0
- package/dist/schemas/schemas.test.d.ts +2 -0
- package/dist/schemas/schemas.test.d.ts.map +1 -0
- package/dist/schemas/schemas.test.js +150 -0
- package/dist/schemas/schemas.test.js.map +1 -0
- package/dist/telescope.d.ts +140 -0
- package/dist/telescope.d.ts.map +1 -0
- package/dist/telescope.js +119 -0
- package/dist/telescope.js.map +1 -0
- package/dist/telescope.test.d.ts +2 -0
- package/dist/telescope.test.d.ts.map +1 -0
- package/dist/telescope.test.js +91 -0
- package/dist/telescope.test.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/types.test-d.d.ts +2 -0
- package/dist/types.test-d.d.ts.map +1 -0
- package/dist/types.test-d.js +28 -0
- package/dist/types.test-d.js.map +1 -0
- package/dist/wallet-compat.test-d.d.ts +13 -0
- package/dist/wallet-compat.test-d.d.ts.map +1 -0
- package/dist/wallet-compat.test-d.js +74 -0
- package/dist/wallet-compat.test-d.js.map +1 -0
- package/package.json +65 -7
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import { createExecuteAdapter, createQueryAdapter } from './telescope.js';
|
|
3
|
+
describe('createQueryAdapter', () => {
|
|
4
|
+
test('converts JSON query to Uint8Array and parses response', async () => {
|
|
5
|
+
const mockSmartContractState = vi.fn().mockResolvedValue({
|
|
6
|
+
data: new TextEncoder().encode(JSON.stringify({ balance: '1000' })),
|
|
7
|
+
});
|
|
8
|
+
const adapter = createQueryAdapter(mockSmartContractState);
|
|
9
|
+
const result = await adapter.queryContractSmart('osmo1contract', {
|
|
10
|
+
balance: { address: 'osmo1abc' },
|
|
11
|
+
});
|
|
12
|
+
expect(result).toEqual({ balance: '1000' });
|
|
13
|
+
expect(mockSmartContractState).toHaveBeenCalledWith({
|
|
14
|
+
address: 'osmo1contract',
|
|
15
|
+
queryData: new TextEncoder().encode(JSON.stringify({ balance: { address: 'osmo1abc' } })),
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
test('works with createTypedContract', async () => {
|
|
19
|
+
const { createTypedContract } = await import('./contract.js');
|
|
20
|
+
const { cw20QuerySchema } = await import('./schemas/cw20/query.js');
|
|
21
|
+
const mockSmartContractState = vi.fn().mockResolvedValue({
|
|
22
|
+
data: new TextEncoder().encode(JSON.stringify({ balance: '500' })),
|
|
23
|
+
});
|
|
24
|
+
const adapter = createQueryAdapter(mockSmartContractState);
|
|
25
|
+
const contract = createTypedContract(adapter, 'osmo1contract', {
|
|
26
|
+
query: cw20QuerySchema,
|
|
27
|
+
});
|
|
28
|
+
const result = await contract.query('balance', { address: 'osmo1abc' });
|
|
29
|
+
expect(result).toEqual({ balance: '500' });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('createExecuteAdapter', () => {
|
|
33
|
+
const mockSmartContractState = vi.fn().mockResolvedValue({
|
|
34
|
+
data: new TextEncoder().encode(JSON.stringify({})),
|
|
35
|
+
});
|
|
36
|
+
const mockSignAndBroadcast = vi.fn().mockResolvedValue({
|
|
37
|
+
transactionHash: 'abc123',
|
|
38
|
+
});
|
|
39
|
+
const mockEncode = vi.fn().mockReturnValue(new Uint8Array([1, 2, 3]));
|
|
40
|
+
test('encodes msg as JSON bytes and calls signAndBroadcast', async () => {
|
|
41
|
+
const adapter = createExecuteAdapter(mockSmartContractState, mockSignAndBroadcast, mockEncode);
|
|
42
|
+
await adapter.execute('osmo1sender', 'osmo1contract', { transfer: { recipient: 'osmo1abc', amount: '1000' } }, 'auto', 'test memo');
|
|
43
|
+
expect(mockEncode).toHaveBeenCalledWith({
|
|
44
|
+
sender: 'osmo1sender',
|
|
45
|
+
contract: 'osmo1contract',
|
|
46
|
+
msg: new TextEncoder().encode(JSON.stringify({
|
|
47
|
+
transfer: { recipient: 'osmo1abc', amount: '1000' },
|
|
48
|
+
})),
|
|
49
|
+
funds: [],
|
|
50
|
+
});
|
|
51
|
+
expect(mockSignAndBroadcast).toHaveBeenCalledWith('osmo1sender', [
|
|
52
|
+
{
|
|
53
|
+
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
|
54
|
+
value: new Uint8Array([1, 2, 3]),
|
|
55
|
+
},
|
|
56
|
+
], 'auto', 'test memo');
|
|
57
|
+
});
|
|
58
|
+
test('passes funds to encoder', async () => {
|
|
59
|
+
const adapter = createExecuteAdapter(mockSmartContractState, mockSignAndBroadcast, mockEncode);
|
|
60
|
+
const funds = [{ denom: 'uosmo', amount: '100' }];
|
|
61
|
+
await adapter.execute('osmo1sender', 'osmo1contract', { transfer: { recipient: 'osmo1abc', amount: '1000' } }, 'auto', undefined, funds);
|
|
62
|
+
expect(mockEncode).toHaveBeenCalledWith(expect.objectContaining({
|
|
63
|
+
funds,
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
test('query works through execute adapter', async () => {
|
|
67
|
+
const adapter = createExecuteAdapter(mockSmartContractState, mockSignAndBroadcast, mockEncode);
|
|
68
|
+
const result = await adapter.queryContractSmart('osmo1contract', {
|
|
69
|
+
balance: { address: 'osmo1abc' },
|
|
70
|
+
});
|
|
71
|
+
expect(result).toEqual({});
|
|
72
|
+
});
|
|
73
|
+
test('works with createTypedContract and cw20 schema', async () => {
|
|
74
|
+
const { createTypedContract } = await import('./contract.js');
|
|
75
|
+
const { cw20 } = await import('./schemas/cw20/index.js');
|
|
76
|
+
const queryFn = vi.fn().mockResolvedValue({
|
|
77
|
+
data: new TextEncoder().encode(JSON.stringify({ balance: '1000' })),
|
|
78
|
+
});
|
|
79
|
+
const broadcastFn = vi.fn().mockResolvedValue({ hash: 'tx123' });
|
|
80
|
+
const encodeFn = vi.fn().mockReturnValue(new Uint8Array([1]));
|
|
81
|
+
const adapter = createExecuteAdapter(queryFn, broadcastFn, encodeFn);
|
|
82
|
+
const contract = createTypedContract(adapter, 'osmo1contract', cw20);
|
|
83
|
+
await contract.execute('osmo1sender', 'transfer', { recipient: 'osmo1abc', amount: '500' }, 'auto');
|
|
84
|
+
expect(broadcastFn).toHaveBeenCalled();
|
|
85
|
+
expect(encodeFn).toHaveBeenCalledWith(expect.objectContaining({
|
|
86
|
+
sender: 'osmo1sender',
|
|
87
|
+
contract: 'osmo1contract',
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=telescope.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telescope.test.js","sourceRoot":"","sources":["../src/telescope.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;A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EACxC,MAAM,CACP,CAAA;QAED,MAAM,CAAC,WAAW,CAAC,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CACnC,MAAM,CAAC,gBAAgB,CAAC;YACtB,MAAM,EAAE,aAAa;YACrB,QAAQ,EAAE,eAAe;SAC1B,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,SAAS,IAAI,EAAE,CAAA;IACvB,GAAG,EAAE,MAAM,CAAA;CACZ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test-d.d.ts","sourceRoot":"","sources":["../src/types.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { assertType, expectTypeOf, test } from 'vitest';
|
|
2
|
+
test('Coin has denom and amount as string', () => {
|
|
3
|
+
expectTypeOf().toEqualTypeOf();
|
|
4
|
+
expectTypeOf().toEqualTypeOf();
|
|
5
|
+
assertType({ denom: 'uosmo', amount: '1000' });
|
|
6
|
+
// @ts-expect-error - amount must be string, not number
|
|
7
|
+
assertType({ denom: 'uosmo', amount: 1000 });
|
|
8
|
+
});
|
|
9
|
+
test('Coin is readonly', () => {
|
|
10
|
+
expectTypeOf().toBeString();
|
|
11
|
+
expectTypeOf().toBeString();
|
|
12
|
+
});
|
|
13
|
+
test('StdFee has readonly Coin[] amount and string gas', () => {
|
|
14
|
+
expectTypeOf().toEqualTypeOf();
|
|
15
|
+
expectTypeOf().toEqualTypeOf();
|
|
16
|
+
assertType({
|
|
17
|
+
amount: [{ denom: 'uosmo', amount: '500' }],
|
|
18
|
+
gas: '200000',
|
|
19
|
+
});
|
|
20
|
+
// @ts-expect-error - gas must be string, not number
|
|
21
|
+
assertType({ amount: [], gas: 200000 });
|
|
22
|
+
});
|
|
23
|
+
test('StdFee.amount is readonly', () => {
|
|
24
|
+
const fee = { amount: [{ denom: 'uosmo', amount: '1' }], gas: '1' };
|
|
25
|
+
// @ts-expect-error - readonly array, push does not exist
|
|
26
|
+
fee.amount.push({ denom: 'uatom', amount: '1' });
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=types.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../src/types.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGvD,IAAI,CAAC,qCAAqC,EAAE,GAAG,EAAE;IAC/C,YAAY,EAAiB,CAAC,aAAa,EAAU,CAAA;IACrD,YAAY,EAAkB,CAAC,aAAa,EAAU,CAAA;IAEtD,UAAU,CAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAEpD,uDAAuD;IACvD,UAAU,CAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC5B,YAAY,EAAiB,CAAC,UAAU,EAAE,CAAA;IAC1C,YAAY,EAAkB,CAAC,UAAU,EAAE,CAAA;AAC7C,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC5D,YAAY,EAAoB,CAAC,aAAa,EAAmB,CAAA;IACjE,YAAY,EAAiB,CAAC,aAAa,EAAU,CAAA;IAErD,UAAU,CAAS;QACjB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC3C,GAAG,EAAE,QAAQ;KACd,CAAC,CAAA;IAEF,oDAAoD;IACpD,UAAU,CAAS,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACrC,MAAM,GAAG,GAAW,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;IAC3E,yDAAyD;IACzD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet kit type compatibility tests.
|
|
3
|
+
*
|
|
4
|
+
* Verifies that popular Cosmos wallet libraries produce client types
|
|
5
|
+
* compatible with schemos's interfaces. Serves as documentation-by-test:
|
|
6
|
+
* upstream type changes that break compatibility will fail here first.
|
|
7
|
+
*
|
|
8
|
+
* - cosmos-kit: covered in client.test-d.ts (SigningCosmWasmClient ↔ CosmWasmExecuteClient)
|
|
9
|
+
* - graz: multi-chain Record<string, T | null> — requires extraction + null-check
|
|
10
|
+
* - interchain-kit: DirectSigner | AminoSigner — requires telescope adapter
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=wallet-compat.test-d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-compat.test-d.d.ts","sourceRoot":"","sources":["../src/wallet-compat.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet kit type compatibility tests.
|
|
3
|
+
*
|
|
4
|
+
* Verifies that popular Cosmos wallet libraries produce client types
|
|
5
|
+
* compatible with schemos's interfaces. Serves as documentation-by-test:
|
|
6
|
+
* upstream type changes that break compatibility will fail here first.
|
|
7
|
+
*
|
|
8
|
+
* - cosmos-kit: covered in client.test-d.ts (SigningCosmWasmClient ↔ CosmWasmExecuteClient)
|
|
9
|
+
* - graz: multi-chain Record<string, T | null> — requires extraction + null-check
|
|
10
|
+
* - interchain-kit: DirectSigner | AminoSigner — requires telescope adapter
|
|
11
|
+
*/
|
|
12
|
+
import { expectTypeOf, test } from 'vitest';
|
|
13
|
+
test('graz: SigningCosmWasmClient | null is NOT assignable without null-check', () => {
|
|
14
|
+
// @ts-expect-error — null is not assignable to CosmWasmExecuteClient
|
|
15
|
+
expectTypeOf().toMatchTypeOf();
|
|
16
|
+
});
|
|
17
|
+
test('graz: after null-check, SigningCosmWasmClient is assignable', () => {
|
|
18
|
+
expectTypeOf().toMatchTypeOf();
|
|
19
|
+
});
|
|
20
|
+
test('graz: raw Record is NOT assignable (it is a map, not a client)', () => {
|
|
21
|
+
// @ts-expect-error — Record<string, T | null> is not a client
|
|
22
|
+
expectTypeOf().toMatchTypeOf();
|
|
23
|
+
});
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// interchain-kit: useChain().signingClient → SigningClient | null
|
|
26
|
+
// SigningClient = DirectSigner | AminoSigner (interchainjs)
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
test('interchain-kit: SigningClient | null is NOT assignable without null-check', () => {
|
|
29
|
+
// @ts-expect-error — null is not assignable to CosmWasmExecuteClient
|
|
30
|
+
expectTypeOf().toMatchTypeOf();
|
|
31
|
+
});
|
|
32
|
+
test('interchain-kit: non-null SigningClient is NOT assignable to CosmWasmExecuteClient', () => {
|
|
33
|
+
// @ts-expect-error — interchainjs signer has different interface than cosmjs
|
|
34
|
+
expectTypeOf().toMatchTypeOf();
|
|
35
|
+
});
|
|
36
|
+
test('interchain-kit: non-null SigningClient is NOT assignable to CosmWasmQueryClient', () => {
|
|
37
|
+
// @ts-expect-error — no queryContractSmart in cosmjs shape
|
|
38
|
+
expectTypeOf().toMatchTypeOf();
|
|
39
|
+
});
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// telescope adapter: the escape hatch for non-cosmjs clients
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
test('telescope: createQueryAdapter returns CosmWasmQueryClient', () => {
|
|
44
|
+
expectTypeOf().toMatchTypeOf();
|
|
45
|
+
});
|
|
46
|
+
test('telescope: createExecuteAdapter returns CosmWasmExecuteClient', () => {
|
|
47
|
+
expectTypeOf().toMatchTypeOf();
|
|
48
|
+
});
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// interchain-kit + telescope adapter integration
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
test('interchain-kit: adapter + createTypedContract compiles', () => {
|
|
53
|
+
expectTypeOf().toMatchTypeOf();
|
|
54
|
+
// This proves createTypedContract(adapter, addr, schema) will compile
|
|
55
|
+
});
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// StdFee compatibility
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
test('schemos StdFee.amount accepts readonly Coin[]', () => {
|
|
60
|
+
expectTypeOf().toMatchTypeOf();
|
|
61
|
+
});
|
|
62
|
+
test('cosmjs StdFee is assignable to schemos StdFee', () => {
|
|
63
|
+
expectTypeOf().toMatchTypeOf();
|
|
64
|
+
});
|
|
65
|
+
test('interchainjs StdFee is assignable to schemos StdFee', () => {
|
|
66
|
+
expectTypeOf().toExtend();
|
|
67
|
+
});
|
|
68
|
+
test('interchain-kit: signingClient.signAndBroadcast is assignable to SignAndBroadcastFn', () => {
|
|
69
|
+
// interchainjs StdFee uses mutable Coin[] while cosmjs uses readonly Coin[].
|
|
70
|
+
// SignAndBroadcastFn accepts InterchainStdFee (mutable) so that
|
|
71
|
+
// signingClient.signAndBroadcast can be passed directly to createExecuteAdapter.
|
|
72
|
+
expectTypeOf().toExtend();
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=wallet-compat.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-compat.test-d.js","sourceRoot":"","sources":["../src/wallet-compat.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAc3C,IAAI,CAAC,yEAAyE,EAAE,GAAG,EAAE;IAEnF,qEAAqE;IACrE,YAAY,EAAgB,CAAC,aAAa,EAAyB,CAAA;AACrE,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,6DAA6D,EAAE,GAAG,EAAE;IAEvE,YAAY,EAAU,CAAC,aAAa,EAAyB,CAAA;AAC/D,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;IAC1E,8DAA8D;IAC9D,YAAY,EAAkB,CAAC,aAAa,EAAyB,CAAA;AACvE,CAAC,CAAC,CAAA;AAEF,8EAA8E;AAC9E,kEAAkE;AAClE,4DAA4D;AAC5D,8EAA8E;AAE9E,IAAI,CAAC,2EAA2E,EAAE,GAAG,EAAE;IAErF,qEAAqE;IACrE,YAAY,EAAgB,CAAC,aAAa,EAAyB,CAAA;AACrE,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,mFAAmF,EAAE,GAAG,EAAE;IAI7F,6EAA6E;IAC7E,YAAY,EAAU,CAAC,aAAa,EAAyB,CAAA;AAC/D,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,iFAAiF,EAAE,GAAG,EAAE;IAE3F,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
"author": "",
|
|
8
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Type-safe CosmWasm contract interactions, zero codegen",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "wnhlee <2wheeh@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/2wheeh/schemos"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cosmwasm",
|
|
14
|
+
"cosmos",
|
|
15
|
+
"type-safe",
|
|
16
|
+
"json-schema",
|
|
17
|
+
"typescript",
|
|
18
|
+
"wasm",
|
|
19
|
+
"smart-contracts"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./schemas": {
|
|
27
|
+
"import": "./dist/schemas/index.js",
|
|
28
|
+
"types": "./dist/schemas/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./telescope": {
|
|
31
|
+
"import": "./dist/telescope.js",
|
|
32
|
+
"types": "./dist/telescope.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"ajv": "^8.18.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@ark/attest": "^0.56.0",
|
|
44
|
+
"@cosmjs/amino": "^0.38.1",
|
|
45
|
+
"@cosmjs/cosmwasm-stargate": "^0.38.1",
|
|
46
|
+
"@cosmjs/proto-signing": "^0.38.1",
|
|
47
|
+
"@cosmjs/stargate": "^0.38.1",
|
|
48
|
+
"@cosmos-kit/core": "^2.18.1",
|
|
49
|
+
"@interchain-kit/react": "^0.10.1",
|
|
50
|
+
"@interchainjs/cosmos": "^1.21.0",
|
|
51
|
+
"@interchainjs/cosmos-types": "^1.21.0",
|
|
52
|
+
"@interchainjs/types": "^1.21.0",
|
|
53
|
+
"@types/node": "^24.0.0",
|
|
54
|
+
"@xpla/xplajs": "1.7.0",
|
|
55
|
+
"cosmock": "^0.2.0",
|
|
56
|
+
"graz": "^0.4.2",
|
|
57
|
+
"interchainjs": "^1.21.0",
|
|
58
|
+
"json-schema-to-ts": "^3.1.1",
|
|
59
|
+
"osmojs": "16.15.0",
|
|
60
|
+
"typescript": "~5.8.0",
|
|
61
|
+
"vitest": "^4.1.2"
|
|
62
|
+
},
|
|
9
63
|
"scripts": {
|
|
10
|
-
"
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:types": "TYPES=true vitest run",
|
|
67
|
+
"build": "tsc -p tsconfig.build.json",
|
|
68
|
+
"test:e2e": "E2E=true vitest run"
|
|
11
69
|
}
|
|
12
70
|
}
|