Skip to content

Commit

Permalink
Merge pull request #69 from phantasma-io/dev
Browse files Browse the repository at this point in the history
Merge Ledger Changes
  • Loading branch information
TeknoPT authored Nov 27, 2023
2 parents 595a3f2 + 8680742 commit 25cceef
Show file tree
Hide file tree
Showing 306 changed files with 22,381 additions and 20,097 deletions.
13 changes: 13 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
},
env: {
browser: true,
es2017: true,
node: true,
},
};
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false
}
26 changes: 0 additions & 26 deletions .vscode/launch.json

This file was deleted.

14 changes: 8 additions & 6 deletions core/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export * from "./rpc/phantasma";
export * from "./vm/index";
export * from "./tx/index";
export * from "./utils/index";
export * from "./types/index";
export * from "./interfaces/index";
export * from './rpc/phantasma';
export * from './vm/index';
export * from './tx/index';
export * from './utils/index';
export * from './types/index';
export * from './interfaces/index';
export * from './ledger/index';
export * from './link/index';
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion core/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ __exportStar(require("./tx/index"), exports);
__exportStar(require("./utils/index"), exports);
__exportStar(require("./types/index"), exports);
__exportStar(require("./interfaces/index"), exports);
__exportStar(require("./ledger/index"), exports);
__exportStar(require("./link/index"), exports);
20 changes: 20 additions & 0 deletions core/ledger/Address-Transcode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Address } from '../types';
/**
* Gets the address from a private key.
* @param privateKey The private key as a string.
* @returns The address as a string.
*/
export declare const GetAddressFromPrivateKey: (privateKey: string) => string;
/**
* Gets the address from a public key.
* @param publicKey The public key as a string.
* @returns The address as a string.
*/
export declare const GetAddressFromPublicKey: (publicKey: string) => string;
/**
* Gets the address from a public key.
* @param publicKey Public key as a string.
* @returns Address
*/
export declare const GetAddressPublicKeyFromPublicKey: (publicKey: string) => Address;
//# sourceMappingURL=Address-Transcode.d.ts.map
1 change: 1 addition & 0 deletions core/ledger/Address-Transcode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions core/ledger/Address-Transcode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetAddressPublicKeyFromPublicKey = exports.GetAddressFromPublicKey = exports.GetAddressFromPrivateKey = void 0;
var bs58 = __importStar(require("bs58"));
var types_1 = require("../types");
/**
* Gets the address from a private key.
* @param privateKey The private key as a string.
* @returns The address as a string.
*/
var GetAddressFromPrivateKey = function (privateKey) {
var keys = types_1.PhantasmaKeys.fromWIF(privateKey);
var publicKey = keys.Address.Text;
return publicKey;
};
exports.GetAddressFromPrivateKey = GetAddressFromPrivateKey;
/**
* Gets the address from a public key.
* @param publicKey The public key as a string.
* @returns The address as a string.
*/
var GetAddressFromPublicKey = function (publicKey) {
// Assuming Base16.decodeUint8Array is a function that decodes a base16 string to Uint8Array
var pubKeyBytes = types_1.Base16.decodeUint8Array(publicKey);
// Create a new array and set the first two elements
var addrArray = new Uint8Array(34);
addrArray[0] = 1;
// Copy 32 bytes from the 2nd position of pubKeyBytes to addrArray, starting from the 3rd position of addrArray
addrArray.set(pubKeyBytes.slice(0, 32), 2);
return 'P' + bs58.encode(addrArray);
};
exports.GetAddressFromPublicKey = GetAddressFromPublicKey;
/**
* Gets the address from a public key.
* @param publicKey Public key as a string.
* @returns Address
*/
var GetAddressPublicKeyFromPublicKey = function (publicKey) {
var pubKeyBytes = types_1.Base16.decodeUint8Array(publicKey);
// Create a new array and set the first two elements
var addrArray = new Uint8Array(34);
addrArray[0] = 1;
// Copy 32 bytes from the 2nd position of pubKeyBytes to addrArray, starting from the 3rd position of addrArray
addrArray.set(pubKeyBytes.slice(0, 32), 2);
return types_1.Address.FromPublickKey(addrArray);
};
exports.GetAddressPublicKeyFromPublicKey = GetAddressPublicKeyFromPublicKey;
66 changes: 66 additions & 0 deletions core/ledger/Ledger-Commands.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { LedgerConfig } from './interfaces/LedgerConfig';
import { LedgerDeviceInfoResponse } from './interfaces/LedgerDeviceInfoResponse';
/**
*
* @param number
* @param length
* @returns
*/
export declare const LeftPad: (number: any, length: any) => string;
/**
*
* @param balance
* @param decimals
* @returns
*/
export declare const ToWholeNumber: (balance: any, decimals: any) => string;
/**
* Get the device info from the ledger.
* @param config
* @returns
*/
export declare const GetLedgerDeviceInfo: (config: LedgerConfig) => Promise<LedgerDeviceInfoResponse>;
/**
* Get Ledger Account Signer
* @param config
* @param accountIx
* @returns
*/
export declare const GetLedgerAccountSigner: (config: LedgerConfig, accountIx: any) => Promise<any>;
/**
* GetBalanceFromLedger
* @param config
* @param options
* @returns
*/
export declare const GetBalanceFromLedger: (config: LedgerConfig, options: any) => Promise<any>;
/**
* Get Addres from Ledger
* @param config
* @param options
* @returns
*/
export declare const GetAddressFromLedeger: (config: LedgerConfig, options: any) => Promise<string | import("..").PublicKeyResponse>;
/**
* SendTransactionLedger
* @param config
* @param script
* @returns
*/
export declare function SendTransactionLedger(config: LedgerConfig, script: string): Promise<any>;
/**
*
* @param config
* @param privateKey
* @returns
*/
export declare const GetBalanceFromPrivateKey: (config: any, privateKey: any) => Promise<any>;
/**
*
* @param config
* @param mnemonic
* @param index
* @returns
*/
export declare const GetBalanceFromMnemonic: (config: LedgerConfig, mnemonic: string, index: any) => Promise<any>;
//# sourceMappingURL=Ledger-Commands.d.ts.map
1 change: 1 addition & 0 deletions core/ledger/Ledger-Commands.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25cceef

Please sign in to comment.