@@ -15,47 +15,43 @@ import { E } from '@endo/far';
15
15
import { M } from '@endo/patterns' ;
16
16
17
17
import { decodeAddressHook } from '@agoric/cosmic-proto/address-hooks.js' ;
18
- import { fromOnly } from '@agoric/zoe/src/contractSupport/index.js' ;
19
18
import { PendingTxStatus } from '@agoric/fast-usdc/src/constants.js' ;
20
- import { makeFeeTools } from '@agoric/fast-usdc/src/utils/fees.js' ;
21
19
import {
22
20
CctpTxEvidenceShape ,
23
21
EvmHashShape ,
24
22
makeNatAmountShape ,
25
23
} from '@agoric/fast-usdc/src/type-guards.js' ;
24
+ import { makeFeeTools } from '@agoric/fast-usdc/src/utils/fees.js' ;
25
+ import { fromOnly } from '@agoric/zoe/src/contractSupport/index.js' ;
26
26
27
+ import type { HostInterface , HostOf } from '@agoric/async-flow' ;
27
28
import type { FungibleTokenPacketData } from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js' ;
28
29
import type { Amount , Brand , NatAmount , NatValue } from '@agoric/ertp' ;
30
+ import type {
31
+ CctpTxEvidence ,
32
+ EvmHash ,
33
+ FeeConfig ,
34
+ LogFn ,
35
+ NobleAddress ,
36
+ } from '@agoric/fast-usdc/src/types.js' ;
29
37
import type {
30
38
AccountId ,
39
+ ChainHub ,
31
40
Denom ,
32
41
OrchestrationAccount ,
33
- ChainHub ,
34
- CosmosChainAddress ,
35
42
} from '@agoric/orchestration' ;
43
+ import { parseAccountId } from '@agoric/orchestration/src/utils/address.js' ;
36
44
import type { WithdrawToSeat } from '@agoric/orchestration/src/utils/zoe-tools.js' ;
45
+ import type { MapStore } from '@agoric/store' ;
37
46
import type { IBCChannelID , IBCPacket , VTransferIBCEvent } from '@agoric/vats' ;
38
- import type { Zone } from '@agoric/zone' ;
39
- import type { HostOf , HostInterface } from '@agoric/async-flow' ;
40
47
import type { TargetRegistration } from '@agoric/vats/src/bridge-target.js' ;
41
- import type {
42
- NobleAddress ,
43
- FeeConfig ,
44
- EvmHash ,
45
- LogFn ,
46
- CctpTxEvidence ,
47
- } from '@agoric/fast-usdc/src/types.js' ;
48
- import type { ZCF , ZCFSeat } from '@agoric/zoe/src/zoeService/zoe.js' ;
49
- import type { MapStore } from '@agoric/store' ;
50
48
import type { VowTools } from '@agoric/vow' ;
51
- import { parseAccountId } from '@agoric/orchestration/src/utils/address.js' ;
52
- import type { Baggage } from '@agoric/vat-data' ;
53
- import { Fail } from '@endo/errors' ;
49
+ import type { ZCF } from '@agoric/zoe/src/zoeService/zoe.js' ;
50
+ import type { Zone } from '@agoric/zone' ;
51
+ import { makeSupportsCctp } from '../utils/cctp.ts' ;
52
+ import { asMultiset } from '../utils/store.ts' ;
54
53
import type { LiquidityPoolKit } from './liquidity-pool.js' ;
55
54
import type { StatusManager } from './status-manager.js' ;
56
- import { asMultiset } from '../utils/store.ts' ;
57
- import { NOBLE_ICA_BAGGAGE_KEY } from '../fast-usdc.contract.ts' ;
58
- import { makeSupportsCctp } from '../utils/cctp.ts' ;
59
55
60
56
const decodeEventPacket = (
61
57
{ data } : IBCPacket ,
@@ -115,7 +111,7 @@ const makeMintedEarlyKey = (addr: NobleAddress, amount: bigint): string =>
115
111
/** @param {Brand<'nat'> } USDC */
116
112
export const makeAdvanceDetailsShape = ( USDC : Brand < 'nat' > ) =>
117
113
harden ( {
118
- destination : CosmosChainAddressShape ,
114
+ destination : M . string ( ) ,
119
115
forwardingAddress : M . string ( ) ,
120
116
fullAmount : makeNatAmountShape ( USDC ) ,
121
117
txHash : EvmHashShape ,
@@ -128,6 +124,7 @@ export const stateShape = harden({
128
124
sourceChannel : M . string ( ) ,
129
125
remoteDenom : M . string ( ) ,
130
126
mintedEarly : M . remotable ( 'mintedEarly' ) ,
127
+ /** @deprecated */
131
128
intermediateRecipient : M . opt ( CosmosChainAddressShape ) ,
132
129
} ) ;
133
130
@@ -144,22 +141,22 @@ export const stateShape = harden({
144
141
export const prepareSettler = (
145
142
zone : Zone ,
146
143
{
147
- baggage,
148
144
currentChainReference,
149
145
chainHub,
150
146
feeConfig,
147
+ getNobleICA,
151
148
log = makeTracer ( 'Settler' , true ) ,
152
149
statusManager,
153
150
USDC ,
154
151
vowTools,
155
152
withdrawToSeat,
156
153
zcf,
157
154
} : {
158
- baggage : Baggage ;
159
155
/** e.g., `agoric-3` */
160
156
currentChainReference : string ;
161
157
chainHub : ChainHub ;
162
158
feeConfig : FeeConfig ;
159
+ getNobleICA : ( ) => OrchestrationAccount < { chainId : 'noble-1' } > ;
163
160
log ?: LogFn ;
164
161
statusManager : StatusManager ;
165
162
USDC : Brand < 'nat' > ;
@@ -172,20 +169,11 @@ export const prepareSettler = (
172
169
173
170
const supportsCctp = makeSupportsCctp ( chainHub ) ;
174
171
175
- /**
176
- * aka `IntermediateRecipientAccount`. A contract-controlled ICA on Noble that can send `MsgDepositForBurn`.
177
- * retrieve from baggage, until:
178
- * [Allow state shape with new optional fields #10200](https://github.com/Agoric/agoric-sdk/issues/10200)
179
- */
180
- const getNobleICA = ( ) : OrchestrationAccount < { chainId : 'noble-1' } > =>
181
- baggage . get ( NOBLE_ICA_BAGGAGE_KEY ) ;
182
-
183
172
return zone . exoClassKit (
184
173
'Fast USDC Settler' ,
185
174
{
186
175
creator : M . interface ( 'SettlerCreatorI' , {
187
176
monitorMintingDeposits : M . callWhen ( ) . returns ( M . any ( ) ) ,
188
- setIntermediateRecipient : M . call ( CosmosChainAddressShape ) . returns ( ) ,
189
177
} ) ,
190
178
tap : M . interface ( 'SettlerTapI' , {
191
179
receiveUpcall : M . call ( M . record ( ) ) . returns ( M . promise ( ) ) ,
@@ -195,10 +183,9 @@ export const prepareSettler = (
195
183
makeAdvanceDetailsShape ( USDC ) ,
196
184
M . boolean ( ) ,
197
185
) . returns ( ) ,
198
- checkMintedEarly : M . call (
199
- CctpTxEvidenceShape ,
200
- CosmosChainAddressShape ,
201
- ) . returns ( M . boolean ( ) ) ,
186
+ checkMintedEarly : M . call ( CctpTxEvidenceShape , M . string ( ) ) . returns (
187
+ M . boolean ( ) ,
188
+ ) ,
202
189
} ) ,
203
190
self : M . interface ( 'SettlerSelfI' , {
204
191
addMintedEarly : M . call ( M . string ( ) , M . nat ( ) ) . returns ( ) ,
@@ -226,13 +213,12 @@ export const prepareSettler = (
226
213
settlementAccount : HostInterface <
227
214
OrchestrationAccount < { chainId : 'agoric-any' } >
228
215
> ;
229
- intermediateRecipient ?: CosmosChainAddress ;
230
216
} ) => {
231
217
log ( 'config' , config ) ;
232
218
return {
233
219
...config ,
234
- // make sure the state record has this property, perhaps with an undefined value
235
- intermediateRecipient : config . intermediateRecipient ,
220
+ // This comes from a power now but the schema requires this key to be set
221
+ intermediateRecipient : undefined ,
236
222
registration : undefined as
237
223
| HostInterface < TargetRegistration >
238
224
| undefined ,
@@ -252,9 +238,6 @@ export const prepareSettler = (
252
238
assert . typeof ( registration , 'object' ) ;
253
239
this . state . registration = registration ;
254
240
} ,
255
- setIntermediateRecipient ( intermediateRecipient : CosmosChainAddress ) {
256
- this . state . intermediateRecipient = intermediateRecipient ;
257
- } ,
258
241
} ,
259
242
tap : {
260
243
async receiveUpcall ( event : VTransferIBCEvent ) {
@@ -310,24 +293,21 @@ export const prepareSettler = (
310
293
txHash : EvmHash ;
311
294
forwardingAddress : NobleAddress ;
312
295
fullAmount : Amount < 'nat' > ;
313
- destination : CosmosChainAddress ;
296
+ destination : AccountId ;
314
297
} ,
315
298
success : boolean ,
316
299
) : void {
317
300
const { mintedEarly } = this . state ;
318
301
const { value : fullValue } = fullAmount ;
319
302
const key = makeMintedEarlyKey ( forwardingAddress , fullValue ) ;
303
+
320
304
if ( mintedEarly . has ( key ) ) {
321
305
asMultiset ( mintedEarly ) . remove ( key ) ;
322
306
statusManager . advanceOutcomeForMintedEarly ( txHash , success ) ;
323
307
if ( success ) {
324
308
void this . facets . self . disburse ( txHash , fullValue ) ;
325
309
} else {
326
- void this . facets . self . forward (
327
- txHash ,
328
- fullValue ,
329
- destination . value ,
330
- ) ;
310
+ void this . facets . self . forward ( txHash , fullValue , destination ) ;
331
311
}
332
312
} else {
333
313
statusManager . advanceOutcome ( forwardingAddress , fullValue , success ) ;
@@ -338,12 +318,12 @@ export const prepareSettler = (
338
318
* funds to the pool.
339
319
*
340
320
* @param {CctpTxEvidence } evidence
341
- * @param {CosmosChainAddress } destination
321
+ * @param {AccountId } destination
342
322
* @returns {boolean } whether the EUD received funds without an advance
343
323
*/
344
324
checkMintedEarly (
345
325
evidence : CctpTxEvidence ,
346
- destination : CosmosChainAddress ,
326
+ destination : AccountId ,
347
327
) : boolean {
348
328
const {
349
329
tx : { forwardingAddress, amount } ,
@@ -359,7 +339,7 @@ export const prepareSettler = (
359
339
) ;
360
340
asMultiset ( mintedEarly ) . remove ( key ) ;
361
341
statusManager . advanceOutcomeForUnknownMint ( evidence ) ;
362
- void this . facets . self . forward ( txHash , amount , destination . value ) ;
342
+ void this . facets . self . forward ( txHash , amount , destination ) ;
363
343
return true ;
364
344
}
365
345
return false ;
@@ -418,9 +398,8 @@ export const prepareSettler = (
418
398
* @param {string } EUD
419
399
*/
420
400
forward ( txHash : EvmHash , fullValue : NatValue , EUD : string ) {
421
- const { settlementAccount, intermediateRecipient } = this . state ;
401
+ const { settlementAccount } = this . state ;
422
402
log ( 'forwarding' , fullValue , 'to' , EUD , 'for' , txHash ) ;
423
- if ( ! intermediateRecipient ) throw Fail `No intermediate recipient` ;
424
403
425
404
const dest : AccountId | null = ( ( ) => {
426
405
try {
@@ -436,6 +415,8 @@ export const prepareSettler = (
436
415
const { namespace, reference } = parseAccountId ( dest ) ;
437
416
const amt = AmountMath . make ( USDC , fullValue ) ;
438
417
418
+ const intermediateRecipient = getNobleICA ( ) . getAddress ( ) ;
419
+
439
420
if ( namespace === 'cosmos' ) {
440
421
const transferOrSendV =
441
422
reference === currentChainReference
0 commit comments