1
1
import {
2
2
Context ,
3
3
Instruction ,
4
- PublicKey ,
5
4
publicKey ,
6
5
Signer ,
7
6
TransactionBuilder ,
8
7
} from '@metaplex-foundation/umi' ;
9
- import {
10
- executeCollectionV1 ,
11
- executeV1 ,
12
- findAssetSignerPda ,
13
- findCollectionSignerPda ,
14
- } from '../generated' ;
8
+ import { executeV1 , findAssetSignerPda } from '../generated' ;
15
9
16
10
export type ExecuteInput = TransactionBuilder | Instruction ;
17
11
@@ -25,29 +19,14 @@ export type ExecuteArgs = Omit<
25
19
signers ?: Signer [ ] ;
26
20
} ;
27
21
28
- export type ExecuteCollectionArgs = Omit <
29
- Parameters < typeof executeCollectionV1 > [ 1 ] ,
30
- 'programId' | 'instructionData'
31
- > & {
32
- builder ?: TransactionBuilder ;
33
- instruction ?: Instruction ;
34
- instructions ?: Instruction [ ] ;
35
- signers ?: Signer [ ] ;
36
- } ;
37
-
38
22
export const execute = (
39
23
context : Pick < Context , 'payer' | 'programs' | 'eddsa' | 'identity' > ,
40
24
args : ExecuteArgs
41
25
) => executeCommon ( context , args ) ;
42
26
43
- export const executeCollection = (
44
- context : Pick < Context , 'payer' | 'programs' | 'eddsa' | 'identity' > ,
45
- args : ExecuteCollectionArgs
46
- ) => executeCommon ( context , args ) ;
47
-
48
27
const executeCommon = (
49
28
context : Pick < Context , 'payer' | 'programs' | 'eddsa' | 'identity' > ,
50
- args : ExecuteArgs | ExecuteCollectionArgs
29
+ args : ExecuteArgs
51
30
) => {
52
31
// Create a new builder to store the translated Execute instructions.
53
32
let executeBuilder = new TransactionBuilder ( ) ;
@@ -86,33 +65,18 @@ const executeCommon = (
86
65
87
66
// eslint-disable-next-line no-restricted-syntax
88
67
for ( const ix of builder . items ) {
89
- let baseBuilder : TransactionBuilder ;
90
- let assetSigner : PublicKey ;
91
- if ( 'asset' in args ) {
92
- [ assetSigner ] = findAssetSignerPda ( context , {
93
- asset : publicKey ( args . asset ) ,
94
- } ) ;
95
- baseBuilder = executeV1 ( context , {
96
- ...args ,
97
- assetSigner,
98
- // Forward the programID of the instruction being executed.
99
- programId : ix . instruction . programId ,
100
- // Forward the data of the instruction being executed.
101
- instructionData : ix . instruction . data ,
102
- } ) ;
103
- } else {
104
- [ assetSigner ] = findCollectionSignerPda ( context , {
105
- collection : publicKey ( args . collection ) ,
106
- } ) ;
107
- baseBuilder = executeCollectionV1 ( context , {
108
- ...args ,
109
- collectionSigner : assetSigner ,
110
- // Forward the programID of the instruction being executed.
111
- programId : ix . instruction . programId ,
112
- // Forward the data of the instruction being executed.
113
- instructionData : ix . instruction . data ,
114
- } ) ;
115
- }
68
+ const [ assetSigner ] = findAssetSignerPda ( context , {
69
+ asset : publicKey ( args . asset ) ,
70
+ } ) ;
71
+ const baseBuilder = executeV1 ( context , {
72
+ ...args ,
73
+ assetSigner,
74
+ // Forward the programID of the instruction being executed.
75
+ programId : ix . instruction . programId ,
76
+ // Forward the data of the instruction being executed.
77
+ instructionData : ix . instruction . data ,
78
+ } ) ;
79
+
116
80
executeBuilder = executeBuilder . add (
117
81
baseBuilder
118
82
// Add the instruction keys as remaining accounts.
0 commit comments