@hawksightco/hawk-sdk 1.1.20 → 1.1.21
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IyfMainIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/IyfMainIxGenerator.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAA6C,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAKjG,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,cAAc,EAAE,IAAI,CAAC,sBAAsB,CAAC;CAC7C,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC;IACnC,uBAAuB,EAAE,IAAI,CAAC,SAAS,CAAC;IACxC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC;IAChC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC;IACnC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC;IAC/B,iBAAiB,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC;IACpC,WAAW,EAAE,IAAI,CA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,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAqCjC,cAAc,CAAC,EACnB,UAAU,EACV,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,eAAe,EACf,WAAW,EACX,cAAc,EACd,4BAA4B,GAC7B,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAwGlD"}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,6 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.IyfMainIxGenerator = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
13
37
|
const anchor_1 = require("../anchor");
|
|
14
38
|
const hawksight_1 = require("../hawksight");
|
|
15
39
|
const functions_1 = require("../functions");
|
|
@@ -104,19 +128,43 @@ class IyfMainIxGenerator {
|
|
|
104
128
|
}
|
|
105
129
|
// Defaults to false
|
|
106
130
|
let ataExists = false;
|
|
131
|
+
// Generate STA and ATA
|
|
132
|
+
const destATA = (0, functions_1.generateAta)(userPda, destinationMint);
|
|
133
|
+
const destSTA = (0, functions_1.generateUserPdaStorageAccount)(userPda, destinationMint);
|
|
134
|
+
// createAtaIx
|
|
135
|
+
let createAtaIx;
|
|
136
|
+
if (destATA.equals(destinationTokenAccount)) {
|
|
137
|
+
[createAtaIx] = (0, functions_1.createAtaIdempotentIxs)({
|
|
138
|
+
accounts: [{
|
|
139
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
140
|
+
mint: destinationMint,
|
|
141
|
+
owner: userPda,
|
|
142
|
+
}]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (destSTA.equals(destinationTokenAccount)) {
|
|
146
|
+
createAtaIx = yield anchor_1.Anchor.instance().iyfMain
|
|
147
|
+
.methods
|
|
148
|
+
.initializeStorageTokenAccount()
|
|
149
|
+
.accounts({
|
|
150
|
+
userPda,
|
|
151
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
152
|
+
mint: destinationMint,
|
|
153
|
+
storageTokenAccount: destSTA,
|
|
154
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
155
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
156
|
+
systemProgram: web3.SystemProgram.programId,
|
|
157
|
+
})
|
|
158
|
+
.instruction();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(`destinationTokenAccount: ${destinationTokenAccount} is neither ATA(${destATA}) or STA${destSTA}`);
|
|
162
|
+
}
|
|
107
163
|
// Flag must be enabled first to check ATA onchain
|
|
108
164
|
if (checkDestinationTokenAccount) {
|
|
109
165
|
const info = yield connection.getAccountInfo(destinationTokenAccount);
|
|
110
166
|
ataExists = !(info === null || info === undefined);
|
|
111
167
|
}
|
|
112
|
-
// Generate create idempotent ata instruction
|
|
113
|
-
const [createAtaIx] = (0, functions_1.createAtaIdempotentIxs)({
|
|
114
|
-
accounts: [{
|
|
115
|
-
payer: addresses_1.HS_AUTHORITY,
|
|
116
|
-
mint: destinationMint,
|
|
117
|
-
owner: userPda,
|
|
118
|
-
}]
|
|
119
|
-
});
|
|
120
168
|
const closeAtaIx = yield anchor_1.Anchor.instance().iyfMain
|
|
121
169
|
.methods
|
|
122
170
|
.closeAta()
|