@@ -17,8 +17,10 @@ async function buildTransferPublicTxOffline(recipientAddress: Address, amount: n
17
17
const feePublicKeyBytes = await getLocalKey ( < string > keyPaths [ CREDITS_PROGRAM_KEYS . fee_public . locator ] ) ;
18
18
const transferPublicAsSignerKeyBytes = await getLocalKey ( < string > keyPaths [ CREDITS_PROGRAM_KEYS . transfer_public_as_signer . locator ] ) ;
19
19
const feePublicProvingKey = ProvingKey . fromBytes ( feePublicKeyBytes ) ;
20
- const transferPublicProvingKey = ProvingKey . fromBytes ( transferPublicAsSignerKeyBytes ) ;
21
-
20
+ const transferPublicProvingKey = ProvingKey . fromBytes (
21
+ await getLocalKey ( < string > keyPaths [ CREDITS_PROGRAM_KEYS . transfer_public . locator ] )
22
+ ) ;
23
+
22
24
// Create an offline key provider
23
25
console . log ( "Creating offline key provider" ) ;
24
26
const offlineKeyProvider = new OfflineKeyProvider ( ) ;
@@ -27,10 +29,25 @@ async function buildTransferPublicTxOffline(recipientAddress: Address, amount: n
27
29
// keys into the key manager.
28
30
console . log ( "Inserting proving keys into key provider" ) ;
29
31
offlineKeyProvider . insertFeePublicKeys ( feePublicProvingKey ) ;
32
+
33
+ try {
30
34
offlineKeyProvider . insertTransferPublicKeys ( transferPublicProvingKey ) ;
35
+ console . log ( "Successfully inserted proving key" ) ;
36
+ } catch ( err ) {
37
+ console . error ( "Failed to insert proving key:" , err ) ;
38
+ }
39
+
31
40
32
41
// Create an offline query to complete the inclusion proof
33
- const offlineQuery = new OfflineQuery ( latestStateRoot ) ;
42
+ let offlineQuery : OfflineQuery ;
43
+ const blockHeight = 0 ;
44
+ // TODO this is a placeholder block height for now, which offlineQuery now requires
45
+ try {
46
+ const offlineQuery = new OfflineQuery ( blockHeight , latestStateRoot ) ;
47
+ console . log ( "Successfully created OfflineQuery" , offlineQuery ) ;
48
+ } catch ( err ) {
49
+ console . error ( "Failed to create OfflineQuery:" , err ) ;
50
+ }
34
51
35
52
// Insert the key provider into the program manager
36
53
programManager . setKeyProvider ( offlineKeyProvider ) ;
@@ -84,13 +101,10 @@ async function buildBondingTxOffline(stakerAddress: Address, validatorAddress:
84
101
// Build the bonding transactions offline
85
102
console . log ( "Building a bond_public execution transaction offline" ) ;
86
103
const bondPublicOptions = {
87
- executionParams : {
88
- keySearchParams : OfflineSearchParams . bondPublicKeyParams ( )
89
- } ,
90
- offlineParams : {
91
- offlineQuery : new OfflineQuery ( latestStateRoot )
92
- }
93
- }
104
+ keySearchParams : OfflineSearchParams . bondPublicKeyParams ( ) ,
105
+ offlineQuery : new OfflineQuery ( latestStateRoot )
106
+ } ;
107
+
94
108
95
109
const bondTx = < Transaction > await programManager . buildBondPublicTransaction (
96
110
stakerAddress . to_string ( ) ,
@@ -103,27 +117,19 @@ async function buildBondingTxOffline(stakerAddress: Address, validatorAddress:
103
117
104
118
console . log ( "Building an unbond_public execution transaction offline" )
105
119
const unbondPublicOptions = {
106
- executionParams : {
107
- keySearchParams : OfflineSearchParams . unbondPublicKeyParams ( )
108
- } ,
109
- offlineParams : {
110
- offlineQuery : new OfflineQuery ( latestStateRoot )
111
- }
112
- }
120
+ keySearchParams : OfflineSearchParams . unbondPublicKeyParams ( ) ,
121
+ offlineQuery : new OfflineQuery ( latestStateRoot )
122
+ } ;
113
123
114
124
const unBondTx = < Transaction > await programManager . buildUnbondPublicTransaction ( stakerAddress . to_string ( ) , amount , unbondPublicOptions ) ;
115
125
console . log ( "\nunbond_public transaction built!\n" ) ;
116
126
117
127
console . log ( "Building a claim_unbond_public transaction offline" )
118
128
// Build the claim unbonding transaction offline
119
129
const claimUnbondPublicOptions = {
120
- executionParams : {
121
- keySearchParams : OfflineSearchParams . claimUnbondPublicKeyParams ( )
122
- } ,
123
- offlineParams : {
124
- offlineQuery : new OfflineQuery ( latestStateRoot )
125
- }
126
- }
130
+ keySearchParams : OfflineSearchParams . claimUnbondPublicKeyParams ( ) ,
131
+ offlineQuery : new OfflineQuery ( latestStateRoot )
132
+ } ;
127
133
128
134
const claimUnbondTx = < Transaction > await programManager . buildClaimUnbondPublicTransaction ( stakerAddress . to_string ( ) , claimUnbondPublicOptions ) ;
129
135
console . log ( "\nclaim_unbond_public transaction built!\n" ) ;
0 commit comments