@agoric/orchestration 0.1.1-dev-19b9351.0 → 0.1.1-dev-6e4ca98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/exos/packet-tools.d.ts +1 -1
- package/tools/contract-tests.d.ts.map +1 -1
- package/tools/contract-tests.ts +19 -4
- package/tools/ibc-mocks.d.ts +28 -10
- package/tools/ibc-mocks.d.ts.map +1 -1
- package/tools/ibc-mocks.ts +57 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-6e4ca98.0+6e4ca98",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"typeCoverage": {
|
|
106
106
|
"atLeast": 97.7
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "6e4ca9802c41073270ea8d52ade0db764e8f19ea"
|
|
109
109
|
}
|
|
@@ -3,7 +3,7 @@ export function preparePacketTools(zone: import("@agoric/base-zone").Zone, vowTo
|
|
|
3
3
|
getBalance(brand: Brand<"nat">): import("@agoric/vow").PromiseVow<Amount<"nat">>;
|
|
4
4
|
deposit(payment: ERef<Payment<"nat">>, optAmountShape?: Pattern): import("@agoric/vow").PromiseVow<Amount<"nat">>;
|
|
5
5
|
withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<Payment<"nat">>;
|
|
6
|
-
executeTx<MT extends import("@agoric/cosmic-proto").TypedJson[]>(messages: MT): PromiseVowOfTupleMappedToGenerics<
|
|
6
|
+
executeTx<MT extends import("@agoric/cosmic-proto").TypedJson[]>(messages: MT): PromiseVowOfTupleMappedToGenerics<ResponseToMany<MT>>;
|
|
7
7
|
monitorTransfers(tap: TargetApp): import("@agoric/vow").PromiseVow<TargetRegistration>;
|
|
8
8
|
}>) => import("@endo/exo").Guarded<{
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-tests.d.ts","sourceRoot":"","sources":["contract-tests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yDAAyD,CAAC;AAS3F,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"contract-tests.d.ts","sourceRoot":"","sources":["contract-tests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yDAAyD,CAAC;AAS3F,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAmBtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAS5C,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAU,UAE1C;IACD,GAAG,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;CACnC;;;;;;;;;uBAsQ+1U,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA3Cz1U;;eAEG;kCACmB,MAAM,GAAG,OAAO,EAAE;;;;;4BA9GtC,CAAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAAC,CAAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAmIH,kGAAkG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCA/InE,MAAM;qBAT9B,WAAW;sBACV,MAAM;;;wCA2DT,iBAAiB,CAAC,OAAO,CAAC,SAC1B,MAAM,GAAG;YAAE,OAAO,EAAE,WAAW,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,yBACnC,MAAM;;;EA4GhC,CAAC"}
|
package/tools/contract-tests.ts
CHANGED
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
} from '@agoric/vats';
|
|
15
15
|
import { prepareBridgeTargetModule } from '@agoric/vats/src/bridge-target.js';
|
|
16
16
|
import { makeWellKnownSpaces } from '@agoric/vats/src/core/utils.js';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
prepareLocalChainTools,
|
|
19
|
+
type AdditionalTransferPowers,
|
|
20
|
+
} from '@agoric/vats/src/localchain.js';
|
|
18
21
|
import { prepareTransferTools } from '@agoric/vats/src/transfer.js';
|
|
19
22
|
import { makeFakeBankManagerKit } from '@agoric/vats/tools/bank-utils.js';
|
|
20
23
|
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
|
|
@@ -94,14 +97,26 @@ export const setupOrchestrationTest = async ({
|
|
|
94
97
|
const inspectLocalBridge = () =>
|
|
95
98
|
harden(localBridgeLog.map(entry => entry.obj));
|
|
96
99
|
|
|
97
|
-
const
|
|
100
|
+
const powersForTransfer = rootZone.weakMapStore(
|
|
101
|
+
'powersForTransfer',
|
|
102
|
+
) as AdditionalTransferPowers;
|
|
103
|
+
const makeLocalChain = prepareLocalChainTools(
|
|
98
104
|
rootZone.subZone('localchain'),
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
{
|
|
106
|
+
...vowTools,
|
|
107
|
+
powersForTransfer,
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
const localchain = makeLocalChain({
|
|
101
111
|
bankManager,
|
|
102
112
|
system: localchainBridge,
|
|
103
113
|
transfer: transferMiddleware,
|
|
104
114
|
});
|
|
115
|
+
powersForTransfer.init(
|
|
116
|
+
transferMiddleware,
|
|
117
|
+
harden({ transferBridgeManager: transferBridge }),
|
|
118
|
+
);
|
|
119
|
+
|
|
105
120
|
const timer = buildZoeManualTimer(log);
|
|
106
121
|
const board = makeFakeBoard();
|
|
107
122
|
const marshaller = board.getPublishingMarshaller();
|
package/tools/ibc-mocks.d.ts
CHANGED
|
@@ -14,31 +14,49 @@ interface EncoderCommon<T> {
|
|
|
14
14
|
typeUrl: string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Build a response "packet bytes string" we'd expect to see from a
|
|
18
|
-
* Response
|
|
17
|
+
* Build a response "packet bytes string" we'd expect to see from a
|
|
18
|
+
* Response to a Tx carrying a single Msg.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param Encoder
|
|
20
|
+
* @deprecated Use `buildTxResponseString([{ encoder, message }])` instead.
|
|
21
|
+
* @param encoder
|
|
23
22
|
* @param message
|
|
24
23
|
*/
|
|
25
|
-
export declare function buildMsgResponseString<T>(
|
|
24
|
+
export declare function buildMsgResponseString<T>(encoder: EncoderCommon<T>, message: Partial<T>): string;
|
|
25
|
+
type EncoderMessage<T> = {
|
|
26
|
+
encoder: EncoderCommon<T>;
|
|
27
|
+
message: Partial<T>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @param messages
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildTxResponseString<T extends EncoderMessage<any>[]>(messages: T): string;
|
|
26
33
|
/**
|
|
27
34
|
* Build an example error packet for a failed Tx Msg
|
|
28
35
|
* @param msg
|
|
29
36
|
*/
|
|
30
37
|
export declare function buildMsgErrorString(msg?: string): string;
|
|
31
38
|
/**
|
|
32
|
-
* Build a response "packet bytes string" we'd expect to see from a Query
|
|
39
|
+
* Build a response "packet bytes string" we'd expect to see from a single Query
|
|
33
40
|
* request
|
|
34
41
|
*
|
|
35
|
-
*
|
|
42
|
+
* @deprecated Use `buildQueriesResponseString([{ encoder, query, opts }])` instead.
|
|
36
43
|
*
|
|
37
|
-
* @param
|
|
44
|
+
* @param encoder
|
|
38
45
|
* @param query
|
|
39
46
|
* @param opts
|
|
40
47
|
*/
|
|
41
|
-
export declare function buildQueryResponseString<T>(
|
|
48
|
+
export declare function buildQueryResponseString<T>(encoder: EncoderCommon<T>, query: Partial<T>, opts?: Partial<Omit<ResponseQuery, 'key'>>): string;
|
|
49
|
+
/**
|
|
50
|
+
* Build a response "packet bytes string" we'd expect to see from
|
|
51
|
+
* the Responses corresponding to multiple Queries.
|
|
52
|
+
* @param queries
|
|
53
|
+
* @returns {string} base64 encoded string of the response packet
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildQueriesResponseString<T extends {
|
|
56
|
+
encoder: EncoderCommon<any>;
|
|
57
|
+
query: Partial<any>;
|
|
58
|
+
opts?: Partial<Omit<ResponseQuery, 'key'>>;
|
|
59
|
+
}[]>(queries: T): string;
|
|
42
60
|
/**
|
|
43
61
|
* Build a tx packet string for the mocked dibc bridge handler
|
|
44
62
|
* @param msgs
|
package/tools/ibc-mocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AgB,CAAC,CAAC,SAAS,iBAAiB,CAAC,OAAO,CAAC,IAAI,OAAO,CACnE,iBAAiB,EACjB;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,eAAe,EAC3D,MAAM,EAAE,CAAC,GACR,yBAAyB,CAAC,CAAC,CAAC,CA4D9B;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,MAOtD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GAAI,yBAG3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAM,KAAG,OAAO,CACxD,QAAQ,CAAC,qBAAqB,CAAC,CAQ/B,CAAC"}
|
package/tools/ibc-mocks.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @file Tools to support making IBC mocks */
|
|
2
2
|
import { type JsonSafe, toRequestQueryJson } from '@agoric/cosmic-proto';
|
|
3
3
|
import { TxBody } from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
|
|
4
|
+
import { TxMsgData } from '@agoric/cosmic-proto/cosmos/base/abci/v1beta1/abci.js';
|
|
4
5
|
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';
|
|
5
6
|
import { FungibleTokenPacketData } from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
|
|
6
7
|
import type { PacketSDKType } from '@agoric/cosmic-proto/ibc/core/channel/v1/channel.js';
|
|
@@ -36,34 +37,47 @@ const toPacket = (obj: Record<string, any>): string =>
|
|
|
36
37
|
btoa(JSON.stringify(obj));
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* Build a response "packet bytes string" we'd expect to see from a
|
|
40
|
-
* Response
|
|
40
|
+
* Build a response "packet bytes string" we'd expect to see from a
|
|
41
|
+
* Response to a Tx carrying a single Msg.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @param Encoder
|
|
43
|
+
* @deprecated Use `buildTxResponseString([{ encoder, message }])` instead.
|
|
44
|
+
* @param encoder
|
|
45
45
|
* @param message
|
|
46
46
|
*/
|
|
47
47
|
export function buildMsgResponseString<T>(
|
|
48
|
-
|
|
48
|
+
encoder: EncoderCommon<T>,
|
|
49
49
|
message: Partial<T>,
|
|
50
50
|
): string {
|
|
51
|
-
|
|
51
|
+
return buildTxResponseString([{ encoder, message }] as const);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type EncoderMessage<T> = {
|
|
55
|
+
encoder: EncoderCommon<T>;
|
|
56
|
+
message: Partial<T>;
|
|
57
|
+
};
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @param messages
|
|
61
|
+
*/
|
|
62
|
+
export function buildTxResponseString<T extends EncoderMessage<any>[]>(
|
|
63
|
+
messages: T,
|
|
64
|
+
): string {
|
|
65
|
+
const msgResponses = messages.map(({ encoder, message }) => {
|
|
66
|
+
const encodedMsg = encoder.encode(encoder.fromPartial(message)).finish();
|
|
67
|
+
return Any.fromPartial({
|
|
68
|
+
typeUrl: encoder.typeUrl,
|
|
69
|
+
value: encodedMsg,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const txMsgData = TxMsgData.encode(
|
|
74
|
+
TxMsgData.fromPartial({
|
|
75
|
+
msgResponses,
|
|
62
76
|
}),
|
|
63
77
|
).finish();
|
|
64
78
|
|
|
65
79
|
return toPacket({
|
|
66
|
-
result: encodeBase64(
|
|
80
|
+
result: encodeBase64(txMsgData),
|
|
67
81
|
});
|
|
68
82
|
}
|
|
69
83
|
|
|
@@ -80,36 +94,43 @@ export function buildMsgErrorString(
|
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
/**
|
|
83
|
-
* Build a response "packet bytes string" we'd expect to see from a Query
|
|
97
|
+
* Build a response "packet bytes string" we'd expect to see from a single Query
|
|
84
98
|
* request
|
|
85
99
|
*
|
|
86
|
-
*
|
|
100
|
+
* @deprecated Use `buildQueriesResponseString([{ encoder, query, opts }])` instead.
|
|
87
101
|
*
|
|
88
|
-
* @param
|
|
102
|
+
* @param encoder
|
|
89
103
|
* @param query
|
|
90
104
|
* @param opts
|
|
91
105
|
*/
|
|
92
106
|
export function buildQueryResponseString<T>(
|
|
93
|
-
|
|
107
|
+
encoder: EncoderCommon<T>,
|
|
94
108
|
query: Partial<T>,
|
|
95
|
-
opts
|
|
96
|
-
value: new Uint8Array(),
|
|
97
|
-
height: 0n,
|
|
98
|
-
index: 0n,
|
|
99
|
-
code: 0,
|
|
100
|
-
log: '',
|
|
101
|
-
info: '',
|
|
102
|
-
codespace: '',
|
|
103
|
-
},
|
|
109
|
+
opts?: Partial<Omit<ResponseQuery, 'key'>>,
|
|
104
110
|
): string {
|
|
111
|
+
return buildQueriesResponseString([{ encoder, query, opts }] as const);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Build a response "packet bytes string" we'd expect to see from
|
|
116
|
+
* the Responses corresponding to multiple Queries.
|
|
117
|
+
* @param queries
|
|
118
|
+
* @returns {string} base64 encoded string of the response packet
|
|
119
|
+
*/
|
|
120
|
+
export function buildQueriesResponseString<
|
|
121
|
+
T extends {
|
|
122
|
+
encoder: EncoderCommon<any>;
|
|
123
|
+
query: Partial<any>;
|
|
124
|
+
opts?: Partial<Omit<ResponseQuery, 'key'>>;
|
|
125
|
+
}[],
|
|
126
|
+
>(queries: T): string {
|
|
105
127
|
const encodedResp = CosmosResponse.encode(
|
|
106
128
|
CosmosResponse.fromPartial({
|
|
107
|
-
responses:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
],
|
|
129
|
+
responses: queries.map(({ encoder, query, opts }) => {
|
|
130
|
+
const key = encoder.encode(encoder.fromPartial(query)).finish();
|
|
131
|
+
const response = ResponseQuery.fromPartial({ ...opts, key });
|
|
132
|
+
return response;
|
|
133
|
+
}),
|
|
113
134
|
}),
|
|
114
135
|
).finish();
|
|
115
136
|
|