@shapeshiftoss/hdwallet-coinbase 1.49.1-alpha.0
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/LICENSE.md +21 -0
- package/dist/adapter.d.ts +10 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +88 -0
- package/dist/adapter.js.map +1 -0
- package/dist/coinbase.d.ts +116 -0
- package/dist/coinbase.d.ts.map +1 -0
- package/dist/coinbase.js +411 -0
- package/dist/coinbase.js.map +1 -0
- package/dist/coinbase.test.d.ts +2 -0
- package/dist/coinbase.test.d.ts.map +1 -0
- package/dist/coinbase.test.js +177 -0
- package/dist/coinbase.test.js.map +1 -0
- package/dist/ethereum.d.ts +9 -0
- package/dist/ethereum.d.ts.map +1 -0
- package/dist/ethereum.js +137 -0
- package/dist/ethereum.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
- package/src/adapter.ts +59 -0
- package/src/coinbase.test.ts +168 -0
- package/src/coinbase.ts +383 -0
- package/src/ethereum.ts +105 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 ShapeShift
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
|
+
import { CoinbaseHDWallet } from "./coinbase";
|
|
3
|
+
export declare class CoinbaseAdapter {
|
|
4
|
+
keyring: core.Keyring;
|
|
5
|
+
private constructor();
|
|
6
|
+
static useKeyring(keyring: core.Keyring): CoinbaseAdapter;
|
|
7
|
+
initialize(): Promise<number>;
|
|
8
|
+
pairDevice(): Promise<CoinbaseHDWallet | undefined>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,qBAAa,eAAe;IAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;IAEtB,OAAO;WAIO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO;IAIjC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,UAAU,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;CAsCjE"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.CoinbaseAdapter = void 0;
|
|
35
|
+
const wallet_sdk_1 = __importDefault(require("@coinbase/wallet-sdk"));
|
|
36
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
37
|
+
const coinbase_1 = require("./coinbase");
|
|
38
|
+
class CoinbaseAdapter {
|
|
39
|
+
constructor(keyring) {
|
|
40
|
+
this.keyring = keyring;
|
|
41
|
+
}
|
|
42
|
+
static useKeyring(keyring) {
|
|
43
|
+
return new CoinbaseAdapter(keyring);
|
|
44
|
+
}
|
|
45
|
+
initialize() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return Object.keys(this.keyring.wallets).length;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
pairDevice() {
|
|
51
|
+
var _a;
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const APP_NAME = "Coinbase Wallet Experiment";
|
|
54
|
+
const APP_LOGO_URL = "https://avatars.githubusercontent.com/u/52928763?s=50&v=4";
|
|
55
|
+
const DEFAULT_ETH_JSONRPC_URL = `https://mainnet.infura.io/v3/key-here`;
|
|
56
|
+
const DEFAULT_CHAIN_ID = 1;
|
|
57
|
+
// Initialize Coinbase Wallet SDK
|
|
58
|
+
const coinbaseWallet = new wallet_sdk_1.default({
|
|
59
|
+
appName: APP_NAME,
|
|
60
|
+
appLogoUrl: APP_LOGO_URL,
|
|
61
|
+
darkMode: false,
|
|
62
|
+
});
|
|
63
|
+
// Initialize a Web3 Provider object
|
|
64
|
+
const coinbaseWalletProvider = coinbaseWallet.makeWeb3Provider(DEFAULT_ETH_JSONRPC_URL, DEFAULT_CHAIN_ID);
|
|
65
|
+
// Initialize a Web3 object
|
|
66
|
+
// const web3 = new Web3(coinbaseWalletProvider as any);
|
|
67
|
+
try {
|
|
68
|
+
const accts = (yield ((_a = coinbaseWalletProvider.request) === null || _a === void 0 ? void 0 : _a.call(coinbaseWalletProvider, { method: "eth_requestAccounts" })));
|
|
69
|
+
console.info(`account address: ${accts[0]}`);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
console.error(`Could not get Coinbase accounts: ${err}`);
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
const wallet = new coinbase_1.CoinbaseHDWallet(coinbaseWalletProvider);
|
|
76
|
+
yield wallet.initialize();
|
|
77
|
+
const deviceID = yield wallet.getDeviceID();
|
|
78
|
+
console.info(`deviceID: ${deviceID}`);
|
|
79
|
+
this.keyring.add(wallet, deviceID);
|
|
80
|
+
this.keyring.emit(["Coinbase", deviceID, core.Events.CONNECT], deviceID);
|
|
81
|
+
// Optionally, have the default account set for web3.js
|
|
82
|
+
// web3.eth.defaultAccount = accounts[0]
|
|
83
|
+
return wallet;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.CoinbaseAdapter = CoinbaseAdapter;
|
|
88
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAqD;AACrD,mEAAqD;AAErD,yCAA8C;AAE9C,MAAa,eAAe;IAG1B,YAAoB,OAAqB;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAqB;QAC5C,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEY,UAAU;;YACrB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAClD,CAAC;KAAA;IAEY,UAAU;;;YACrB,MAAM,QAAQ,GAAG,4BAA4B,CAA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D;YACvD,wCAAwC;YAExC,OAAO,MAAM,CAAC;;KACf;CACF;AArDD,0CAqDC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
|
+
import { AddEthereumChainParameter } from "@shapeshiftoss/hdwallet-core";
|
|
3
|
+
export declare class CoinbaseHDWalletInfo implements core.HDWalletInfo, core.ETHWalletInfo {
|
|
4
|
+
readonly _supportsBTCInfo = false;
|
|
5
|
+
readonly _supportsETHInfo = true;
|
|
6
|
+
readonly _supportsCosmosInfo = false;
|
|
7
|
+
readonly _supportsBinanceInfo = false;
|
|
8
|
+
readonly _supportsRippleInfo = false;
|
|
9
|
+
readonly _supportsEosInfo = false;
|
|
10
|
+
readonly _supportsFioInfo = false;
|
|
11
|
+
readonly _supportsThorchainInfo = false;
|
|
12
|
+
readonly _supportsSecretInfo = false;
|
|
13
|
+
readonly _supportsKavaInfo = false;
|
|
14
|
+
readonly _supportsTerraInfo = false;
|
|
15
|
+
getVendor(): string;
|
|
16
|
+
hasOnDevicePinEntry(): boolean;
|
|
17
|
+
hasOnDevicePassphrase(): boolean;
|
|
18
|
+
hasOnDeviceDisplay(): boolean;
|
|
19
|
+
hasOnDeviceRecovery(): boolean;
|
|
20
|
+
hasNativeShapeShift(srcCoin: core.Coin, dstCoin: core.Coin): boolean;
|
|
21
|
+
supportsBip44Accounts(): boolean;
|
|
22
|
+
supportsOfflineSigning(): boolean;
|
|
23
|
+
supportsBroadcast(): boolean;
|
|
24
|
+
describePath(msg: core.DescribePath): core.PathDescription;
|
|
25
|
+
ethNextAccountPath(msg: core.ETHAccountPath): core.ETHAccountPath | undefined;
|
|
26
|
+
ethSupportsNetwork(chainId: number): Promise<boolean>;
|
|
27
|
+
ethSupportsSecureTransfer(): Promise<boolean>;
|
|
28
|
+
ethSupportsNativeShapeShift(): boolean;
|
|
29
|
+
ethSupportsEIP1559(): Promise<boolean>;
|
|
30
|
+
ethGetAccountPaths(msg: core.ETHGetAccountPath): Array<core.ETHAccountPath>;
|
|
31
|
+
}
|
|
32
|
+
export declare class CoinbaseHDWallet implements core.HDWallet, core.ETHWallet {
|
|
33
|
+
readonly _supportsETH = true;
|
|
34
|
+
readonly _supportsETHInfo = true;
|
|
35
|
+
readonly _supportsBTCInfo = false;
|
|
36
|
+
readonly _supportsBTC = false;
|
|
37
|
+
readonly _supportsCosmosInfo = false;
|
|
38
|
+
readonly _supportsCosmos = false;
|
|
39
|
+
readonly _supportsEthSwitchChain = true;
|
|
40
|
+
readonly _supportsAvalanche = false;
|
|
41
|
+
readonly _supportsOptimism = false;
|
|
42
|
+
readonly _supportsBSC = false;
|
|
43
|
+
readonly _supportsPolygon = true;
|
|
44
|
+
readonly _supportsOsmosisInfo = false;
|
|
45
|
+
readonly _supportsOsmosis = false;
|
|
46
|
+
readonly _supportsBinanceInfo = false;
|
|
47
|
+
readonly _supportsBinance = false;
|
|
48
|
+
readonly _supportsDebugLink = false;
|
|
49
|
+
readonly _isPortis = false;
|
|
50
|
+
readonly _isMetaMask = false;
|
|
51
|
+
readonly _isCoinbase = true;
|
|
52
|
+
readonly _supportsRippleInfo = false;
|
|
53
|
+
readonly _supportsRipple = false;
|
|
54
|
+
readonly _supportsEosInfo = false;
|
|
55
|
+
readonly _supportsEos = false;
|
|
56
|
+
readonly _supportsFioInfo = false;
|
|
57
|
+
readonly _supportsFio = false;
|
|
58
|
+
readonly _supportsThorchainInfo = false;
|
|
59
|
+
readonly _supportsThorchain = false;
|
|
60
|
+
readonly _supportsSecretInfo = false;
|
|
61
|
+
readonly _supportsSecret = false;
|
|
62
|
+
readonly _supportsKava = false;
|
|
63
|
+
readonly _supportsKavaInfo = false;
|
|
64
|
+
readonly _supportsTerra = false;
|
|
65
|
+
readonly _supportsTerraInfo = false;
|
|
66
|
+
info: CoinbaseHDWalletInfo & core.HDWalletInfo;
|
|
67
|
+
ethAddress?: string | null;
|
|
68
|
+
provider: any;
|
|
69
|
+
constructor(provider: unknown);
|
|
70
|
+
getFeatures(): Promise<Record<string, any>>;
|
|
71
|
+
isLocked(): Promise<boolean>;
|
|
72
|
+
getVendor(): string;
|
|
73
|
+
getModel(): Promise<string>;
|
|
74
|
+
getLabel(): Promise<string>;
|
|
75
|
+
initialize(): Promise<void>;
|
|
76
|
+
hasOnDevicePinEntry(): boolean;
|
|
77
|
+
hasOnDevicePassphrase(): boolean;
|
|
78
|
+
hasOnDeviceDisplay(): boolean;
|
|
79
|
+
hasOnDeviceRecovery(): boolean;
|
|
80
|
+
hasNativeShapeShift(srcCoin: core.Coin, dstCoin: core.Coin): boolean;
|
|
81
|
+
supportsBip44Accounts(): boolean;
|
|
82
|
+
supportsOfflineSigning(): boolean;
|
|
83
|
+
supportsBroadcast(): boolean;
|
|
84
|
+
clearSession(): Promise<void>;
|
|
85
|
+
ping(msg: core.Ping): Promise<core.Pong>;
|
|
86
|
+
sendPin(pin: string): Promise<void>;
|
|
87
|
+
sendPassphrase(passphrase: string): Promise<void>;
|
|
88
|
+
sendCharacter(charater: string): Promise<void>;
|
|
89
|
+
sendWord(word: string): Promise<void>;
|
|
90
|
+
cancel(): Promise<void>;
|
|
91
|
+
wipe(): Promise<void>;
|
|
92
|
+
reset(msg: core.ResetDevice): Promise<void>;
|
|
93
|
+
recover(msg: core.RecoverDevice): Promise<void>;
|
|
94
|
+
loadDevice(msg: core.LoadDevice): Promise<void>;
|
|
95
|
+
describePath(msg: core.DescribePath): core.PathDescription;
|
|
96
|
+
getPublicKeys(msg: Array<core.GetPublicKey>): Promise<Array<core.PublicKey | null>>;
|
|
97
|
+
isInitialized(): Promise<boolean>;
|
|
98
|
+
disconnect(): Promise<void>;
|
|
99
|
+
ethSupportsNetwork(chainId?: number): Promise<boolean>;
|
|
100
|
+
ethGetChainId(): Promise<number | null>;
|
|
101
|
+
ethAddChain(params: AddEthereumChainParameter): Promise<void>;
|
|
102
|
+
ethSwitchChain(params: AddEthereumChainParameter): Promise<void>;
|
|
103
|
+
ethSupportsSecureTransfer(): Promise<boolean>;
|
|
104
|
+
ethSupportsNativeShapeShift(): boolean;
|
|
105
|
+
ethSupportsEIP1559(): Promise<boolean>;
|
|
106
|
+
ethGetAccountPaths(msg: core.ETHGetAccountPath): Array<core.ETHAccountPath>;
|
|
107
|
+
ethNextAccountPath(msg: core.ETHAccountPath): core.ETHAccountPath | undefined;
|
|
108
|
+
ethGetAddress(msg: core.ETHGetAddress): Promise<string | null>;
|
|
109
|
+
ethSignTx(msg: core.ETHSignTx): Promise<core.ETHSignedTx | null>;
|
|
110
|
+
ethSendTx(msg: core.ETHSignTx): Promise<core.ETHTxHash | null>;
|
|
111
|
+
ethSignMessage(msg: core.ETHSignMessage): Promise<core.ETHSignedMessage | null>;
|
|
112
|
+
ethVerifyMessage(msg: core.ETHVerifyMessage): Promise<boolean | null>;
|
|
113
|
+
getDeviceID(): Promise<string>;
|
|
114
|
+
getFirmwareVersion(): Promise<string>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=coinbase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coinbase.d.ts","sourceRoot":"","sources":["../src/coinbase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAKzE,qBAAa,oBAAqB,YAAW,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa;IAChF,QAAQ,CAAC,gBAAgB,SAAS;IAClC,QAAQ,CAAC,gBAAgB,QAAQ;IACjC,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,oBAAoB,SAAS;IACtC,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,gBAAgB,SAAS;IAClC,QAAQ,CAAC,gBAAgB,SAAS;IAClC,QAAQ,CAAC,sBAAsB,SAAS;IACxC,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,iBAAiB,SAAS;IACn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,411 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.CoinbaseHDWallet = exports.CoinbaseHDWalletInfo = void 0;
|
|
32
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
33
|
+
const eth_rpc_errors_1 = require("eth-rpc-errors");
|
|
34
|
+
const eth = __importStar(require("./ethereum"));
|
|
35
|
+
class CoinbaseHDWalletInfo {
|
|
36
|
+
constructor() {
|
|
37
|
+
this._supportsBTCInfo = false;
|
|
38
|
+
this._supportsETHInfo = true;
|
|
39
|
+
this._supportsCosmosInfo = false;
|
|
40
|
+
this._supportsBinanceInfo = false;
|
|
41
|
+
this._supportsRippleInfo = false;
|
|
42
|
+
this._supportsEosInfo = false;
|
|
43
|
+
this._supportsFioInfo = false;
|
|
44
|
+
this._supportsThorchainInfo = false;
|
|
45
|
+
this._supportsSecretInfo = false;
|
|
46
|
+
this._supportsKavaInfo = false;
|
|
47
|
+
this._supportsTerraInfo = false;
|
|
48
|
+
}
|
|
49
|
+
getVendor() {
|
|
50
|
+
return "Coinbase";
|
|
51
|
+
}
|
|
52
|
+
hasOnDevicePinEntry() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
hasOnDevicePassphrase() {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
hasOnDeviceDisplay() {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
hasOnDeviceRecovery() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
+
hasNativeShapeShift(srcCoin, dstCoin) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
supportsBip44Accounts() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
supportsOfflineSigning() {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
supportsBroadcast() {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
describePath(msg) {
|
|
78
|
+
switch (msg.coin) {
|
|
79
|
+
case "Ethereum":
|
|
80
|
+
// return eth.describeETHPath(msg.path);
|
|
81
|
+
return core.describeETHPath(msg.path);
|
|
82
|
+
default:
|
|
83
|
+
throw new Error("Unsupported path");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
+
ethNextAccountPath(msg) {
|
|
88
|
+
// TODO: What do we do here?
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
ethSupportsNetwork(chainId) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return chainId === 1;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
ethSupportsSecureTransfer() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
ethSupportsNativeShapeShift() {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
ethSupportsEIP1559() {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
return true;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
ethGetAccountPaths(msg) {
|
|
110
|
+
return eth.ethGetAccountPaths(msg);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.CoinbaseHDWalletInfo = CoinbaseHDWalletInfo;
|
|
114
|
+
class CoinbaseHDWallet {
|
|
115
|
+
constructor(provider) {
|
|
116
|
+
this._supportsETH = true;
|
|
117
|
+
this._supportsETHInfo = true;
|
|
118
|
+
this._supportsBTCInfo = false;
|
|
119
|
+
this._supportsBTC = false;
|
|
120
|
+
this._supportsCosmosInfo = false;
|
|
121
|
+
this._supportsCosmos = false;
|
|
122
|
+
this._supportsEthSwitchChain = true; // maybe?
|
|
123
|
+
this._supportsAvalanche = false;
|
|
124
|
+
this._supportsOptimism = false;
|
|
125
|
+
this._supportsBSC = false;
|
|
126
|
+
this._supportsPolygon = true;
|
|
127
|
+
this._supportsOsmosisInfo = false;
|
|
128
|
+
this._supportsOsmosis = false;
|
|
129
|
+
this._supportsBinanceInfo = false;
|
|
130
|
+
this._supportsBinance = false;
|
|
131
|
+
this._supportsDebugLink = false;
|
|
132
|
+
this._isPortis = false;
|
|
133
|
+
this._isMetaMask = false;
|
|
134
|
+
this._isCoinbase = true;
|
|
135
|
+
this._supportsRippleInfo = false;
|
|
136
|
+
this._supportsRipple = false;
|
|
137
|
+
this._supportsEosInfo = false;
|
|
138
|
+
this._supportsEos = false;
|
|
139
|
+
this._supportsFioInfo = false;
|
|
140
|
+
this._supportsFio = false;
|
|
141
|
+
this._supportsThorchainInfo = false;
|
|
142
|
+
this._supportsThorchain = false;
|
|
143
|
+
this._supportsSecretInfo = false;
|
|
144
|
+
this._supportsSecret = false;
|
|
145
|
+
this._supportsKava = false;
|
|
146
|
+
this._supportsKavaInfo = false;
|
|
147
|
+
this._supportsTerra = false;
|
|
148
|
+
this._supportsTerraInfo = false;
|
|
149
|
+
this.info = new CoinbaseHDWalletInfo();
|
|
150
|
+
this.provider = provider;
|
|
151
|
+
}
|
|
152
|
+
getFeatures() {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
return {};
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
isLocked() {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
return !this.provider._coinbase.isUnlocked();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
getVendor() {
|
|
163
|
+
return "Coinbase";
|
|
164
|
+
}
|
|
165
|
+
getModel() {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
return "Coinbase";
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
getLabel() {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
return "Coinbase";
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
initialize() {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
// nothing to initialize
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
hasOnDevicePinEntry() {
|
|
181
|
+
return this.info.hasOnDevicePinEntry();
|
|
182
|
+
}
|
|
183
|
+
hasOnDevicePassphrase() {
|
|
184
|
+
return this.info.hasOnDevicePassphrase();
|
|
185
|
+
}
|
|
186
|
+
hasOnDeviceDisplay() {
|
|
187
|
+
return this.info.hasOnDeviceDisplay();
|
|
188
|
+
}
|
|
189
|
+
hasOnDeviceRecovery() {
|
|
190
|
+
return this.info.hasOnDeviceRecovery();
|
|
191
|
+
}
|
|
192
|
+
hasNativeShapeShift(srcCoin, dstCoin) {
|
|
193
|
+
return this.info.hasNativeShapeShift(srcCoin, dstCoin);
|
|
194
|
+
}
|
|
195
|
+
supportsBip44Accounts() {
|
|
196
|
+
return this.info.supportsBip44Accounts();
|
|
197
|
+
}
|
|
198
|
+
supportsOfflineSigning() {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
supportsBroadcast() {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
clearSession() {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
// TODO: Can we lock Coinbase from here?
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
ping(msg) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
// no ping function for Coinbase, so just returning Core.Pong
|
|
212
|
+
return { msg: msg.msg };
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
216
|
+
sendPin(pin) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
// no concept of pin in Coinbase
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
222
|
+
sendPassphrase(passphrase) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
// cannot send passphrase to Coinbase. Could show the widget?
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
228
|
+
sendCharacter(charater) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
// no concept of sendCharacter in Coinbase
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
234
|
+
sendWord(word) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
// no concept of sendWord in Coinbase
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
cancel() {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
// no concept of cancel in Coinbase
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
245
|
+
wipe() {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
247
|
+
}
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
|
|
249
|
+
reset(msg) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
251
|
+
}
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
253
|
+
recover(msg) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
// no concept of recover in Coinbase
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
259
|
+
loadDevice(msg) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
// TODO: Does Coinbase allow this to be done programatically?
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
describePath(msg) {
|
|
265
|
+
return this.info.describePath(msg);
|
|
266
|
+
}
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
268
|
+
getPublicKeys(msg) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
// Ethereum public keys are not exposed by the RPC API
|
|
271
|
+
return [];
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
isInitialized() {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
return true;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
280
|
+
disconnect() {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
282
|
+
}
|
|
283
|
+
ethSupportsNetwork(chainId = 1) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
return chainId === 1;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
ethGetChainId() {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
try {
|
|
291
|
+
// chainId as hex string
|
|
292
|
+
const chainId = yield this.provider.request({ method: "eth_chainId" });
|
|
293
|
+
return parseInt(chainId, 16);
|
|
294
|
+
}
|
|
295
|
+
catch (e) {
|
|
296
|
+
console.error(e);
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
ethAddChain(params) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
// at this point, we know that we're in the context of a valid Coinbase provider
|
|
304
|
+
yield this.provider.request({ method: "wallet_addEthereumChain", params: [params] });
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
ethSwitchChain(params) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
try {
|
|
310
|
+
// at this point, we know that we're in the context of a valid Coinbase provider
|
|
311
|
+
yield this.provider.request({ method: "wallet_switchEthereumChain", params: [{ chainId: params.chainId }] });
|
|
312
|
+
}
|
|
313
|
+
catch (e) {
|
|
314
|
+
const error = eth_rpc_errors_1.serializeError(e);
|
|
315
|
+
// https://docs.metamask.io/guide/ethereum-provider.html#errors
|
|
316
|
+
// Internal error, which in the case of wallet_switchEthereumChain call means the chain isn't currently added to the wallet
|
|
317
|
+
if (error.code === -32603) {
|
|
318
|
+
// We only support Avalanche C-Chain currently. It is supported natively in XDEFI, and unsupported in Tally, both with no capabilities to add a new chain
|
|
319
|
+
// TODO(gomes): Find a better home for these. When that's done, we'll want to call ethSwitchChain with (params: AddEthereumChainParameter) instead
|
|
320
|
+
try {
|
|
321
|
+
yield this.ethAddChain(params);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
catch (addChainE) {
|
|
325
|
+
const addChainError = eth_rpc_errors_1.serializeError(addChainE);
|
|
326
|
+
if (addChainError.code === 4001) {
|
|
327
|
+
throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest();
|
|
328
|
+
}
|
|
329
|
+
throw addChainError.data.originalError;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (error.code === 4001) {
|
|
333
|
+
throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest();
|
|
334
|
+
}
|
|
335
|
+
throw error.data.originalError;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
ethSupportsSecureTransfer() {
|
|
340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
+
return false;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
ethSupportsNativeShapeShift() {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
ethSupportsEIP1559() {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
return true;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
ethGetAccountPaths(msg) {
|
|
353
|
+
return eth.ethGetAccountPaths(msg);
|
|
354
|
+
}
|
|
355
|
+
ethNextAccountPath(msg) {
|
|
356
|
+
return this.info.ethNextAccountPath(msg);
|
|
357
|
+
}
|
|
358
|
+
// TODO: Respect msg.addressNList!
|
|
359
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
360
|
+
ethGetAddress(msg) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
if (this.ethAddress) {
|
|
363
|
+
return this.ethAddress;
|
|
364
|
+
}
|
|
365
|
+
const address = yield eth.ethGetAddress(this.provider);
|
|
366
|
+
if (address) {
|
|
367
|
+
this.ethAddress = address;
|
|
368
|
+
return address;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
this.ethAddress = null;
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
ethSignTx(msg) {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
const address = yield this.ethGetAddress(this.provider);
|
|
379
|
+
return address ? eth.ethSignTx(msg, this.provider, address) : null;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
ethSendTx(msg) {
|
|
383
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
+
const address = yield this.ethGetAddress(this.provider);
|
|
385
|
+
return address ? eth.ethSendTx(msg, this.provider, address) : null;
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
ethSignMessage(msg) {
|
|
389
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
const address = yield this.ethGetAddress(this.provider);
|
|
391
|
+
return address ? eth.ethSignMessage(msg, this.provider, address) : null;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
ethVerifyMessage(msg) {
|
|
395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
+
return eth.ethVerifyMessage(msg, this.provider);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
getDeviceID() {
|
|
400
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
return "coinbase:" + (yield this.ethGetAddress(this.provider));
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
getFirmwareVersion() {
|
|
405
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
406
|
+
return "coinbase";
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
exports.CoinbaseHDWallet = CoinbaseHDWallet;
|
|
411
|
+
//# sourceMappingURL=coinbase.js.map
|