@openocean.finance/openocean-sdk 0.1.56 → 0.1.57
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/lib/index.js +2 -20
- package/package.json +1 -1
- package/lib/api/index.js +0 -139
- package/lib/api/vo/RequestVo.js +0 -401
- package/lib/asset/abi/aggregator.js +0 -391
- package/lib/config/Chains.js +0 -504
- package/lib/config/Wallets.js +0 -79
- package/lib/config/index.js +0 -11
- package/lib/swapSdk/Approve.js +0 -229
- package/lib/swapSdk/ConnectWallet.js +0 -283
- package/lib/swapSdk/NotoMobile.js +0 -147
- package/lib/swapSdk/RequestVo.js +0 -94
- package/lib/swapSdk/Swap.js +0 -748
- package/lib/swapSdk/getAllowance.js +0 -97
- package/lib/swapSdk/getBalance.js +0 -221
- package/lib/swapSdk/index.js +0 -267
- package/lib/swapSdk/jupiterDex.d.ts +0 -1
- package/lib/swapSdk/jupiterDex.js +0 -97
- package/lib/swapSdk/qrcode.d.ts +0 -11
- package/lib/swapSdk/qrcode.js +0 -989
- package/lib/utils/ajx.js +0 -150
- package/lib/utils/index.js +0 -92
- package/lib/utils/web3.js +0 -9
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.jupiterDex = void 0;
|
|
40
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
41
|
-
var core_1 = require("@jup-ag/core");
|
|
42
|
-
// index.ts
|
|
43
|
-
var jupiterDex = function (collection, customPublicKey, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var jupiter, routes, bestRoute, execute, swapResult;
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
debugger;
|
|
49
|
-
console.log(res);
|
|
50
|
-
console.log('准备交易-----------------');
|
|
51
|
-
console.log(collection);
|
|
52
|
-
console.log(customPublicKey);
|
|
53
|
-
return [4 /*yield*/, core_1.Jupiter.load({
|
|
54
|
-
connection: collection,
|
|
55
|
-
cluster: 'mainnet-beta',
|
|
56
|
-
user: customPublicKey, // or public key
|
|
57
|
-
})];
|
|
58
|
-
case 1:
|
|
59
|
-
jupiter = _a.sent();
|
|
60
|
-
console.log('jupiter-----------------');
|
|
61
|
-
console.log(jupiter);
|
|
62
|
-
debugger;
|
|
63
|
-
return [4 /*yield*/, jupiter.computeRoutes({
|
|
64
|
-
inputMint: new web3_js_1.PublicKey(res.inToken.address),
|
|
65
|
-
outputMint: new web3_js_1.PublicKey(res.outToken.address),
|
|
66
|
-
inputAmount: res.inAmount,
|
|
67
|
-
slippage: 3 // 1 = 1%
|
|
68
|
-
})];
|
|
69
|
-
case 2:
|
|
70
|
-
routes = _a.sent();
|
|
71
|
-
console.log('路由-----------------');
|
|
72
|
-
console.log(routes);
|
|
73
|
-
debugger;
|
|
74
|
-
bestRoute = routes.routesInfos[0];
|
|
75
|
-
return [4 /*yield*/, jupiter.exchange({
|
|
76
|
-
routeInfo: bestRoute
|
|
77
|
-
})];
|
|
78
|
-
case 3:
|
|
79
|
-
execute = (_a.sent()).execute;
|
|
80
|
-
debugger;
|
|
81
|
-
return [4 /*yield*/, execute()];
|
|
82
|
-
case 4:
|
|
83
|
-
swapResult = _a.sent();
|
|
84
|
-
console.log('交易-----------------');
|
|
85
|
-
console.log(swapResult);
|
|
86
|
-
debugger;
|
|
87
|
-
if (swapResult.error) {
|
|
88
|
-
throw new Error(swapResult.error);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return [2 /*return*/, swapResult.txid];
|
|
92
|
-
}
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}); };
|
|
97
|
-
exports.jupiterDex = jupiterDex;
|
package/lib/swapSdk/qrcode.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* - Using the 'QRCode for Javascript library'
|
|
4
|
-
* - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
|
|
5
|
-
* - this library has no dependencies.
|
|
6
|
-
*
|
|
7
|
-
* @author davidshimjs
|
|
8
|
-
* @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
|
|
9
|
-
* @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
|
|
10
|
-
*/
|
|
11
|
-
export var QRCode: any;
|