Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Faust committed May 15, 2020
1 parent 29c3d7e commit ddfa67f
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 86 deletions.
114 changes: 57 additions & 57 deletions WALLET_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,88 @@

### Generate Cosmos Testnet Wallet

- Install & launch Lunie Chrome Browser extension https://chrome.google.com/webstore/detail/lunie-browser-extension/hbaijkfbhhdhhjdfbpdafkjimohblhgf/related
- Select ‘Create Address’
- Select `Gaia Testnet`
- Enter Account Name
- Enter & confirm password
- Store Backup Code safely
- A cosmos testnet address will then be generated for you
- Install & launch Lunie Chrome Browser extension https://chrome.google.com/webstore/detail/lunie-browser-extension/hbaijkfbhhdhhjdfbpdafkjimohblhgf/related
- Select ‘Create Address’
- Select `Gaia Testnet`
- Enter Account Name
- Enter & confirm password
- Store Backup Code safely
- A cosmos testnet address will then be generated for you

### Receive Cosmos Testnet Tokens

- Visit this Cosmos testnet faucet https://riot.im/app/#/room/%23cosmos-faucet:matrix.org
- Register an account
- Enter “show me the money! <ADDRESS>” into the chatbox
- The address specified will then receive testnet tokens
- Visit this Cosmos testnet faucet https://riot.im/app/#/room/%23cosmos-faucet:matrix.org
- Register an account
- Enter “show me the money! <ADDRESS>” into the chatbox
- The address specified will then receive testnet tokens

## Lisk

### Generate a Lisk Testnet Wallet

- Download the Lisk Wallet https://lisk.io/wallet
- Create Lisk account and follow on-screen instructions
- Sign-In
- Go to Settings
- Enable ‘Network switcher’
- Sign-Out
- Select Sign-In
- At the Sign-In page, change the network to ‘Testnet’
- Enter passphrase to sign in
- Select the ‘Wallet’ tab
- Under ‘Wallet details’, your Lisk testnet address will be displayed.
- Download the Lisk Wallet https://lisk.io/wallet
- Create Lisk account and follow on-screen instructions
- Sign-In
- Go to Settings
- Enable ‘Network switcher’
- Sign-Out
- Select Sign-In
- At the Sign-In page, change the network to ‘Testnet’
- Enter passphrase to sign in
- Select the ‘Wallet’ tab
- Under ‘Wallet details’, your Lisk testnet address will be displayed.

### Receive Lisk Testnet Tokens

- Visit https://testnet-faucet.lisk.io/
- Enter your Lisk Testnet address
- Select ‘Receive my free LSK’
- Visit https://testnet-faucet.lisk.io/
- Enter your Lisk Testnet address
- Select ‘Receive my free LSK’

## EOS

### Generate an EOS Testnet Wallet & Receive Testnet Tokens

- Visit https://testnet.eos.io/
- Register an account
- Sign In
- Select ‘Account Settings’
- Select ‘Blockchain Accounts’
- Select ‘Request Tokens’
- Visit https://testnet.eos.io/
- Register an account
- Sign In
- Select ‘Account Settings’
- Select ‘Blockchain Accounts’
- Select ‘Request Tokens’

## XRP

### Generate XRP Testnet Wallet & Receive Testnet Tokens

- Visit this XRP testnet faucet
- https://xrpl.org/xrp-testnet-faucet.html
- Select ‘Generate Testnet credentials’
- Store ‘Secret’ safely
- An address has been generated that contains testnet tokens
- Visit this XRP testnet faucet
- https://xrpl.org/xrp-testnet-faucet.html
- Select ‘Generate Testnet credentials’
- Store ‘Secret’ safely
- An address has been generated that contains testnet tokens

## NEO

### Generate an NEO Testnet Wallet

- Download the NEON wallet - https://neonwallet.com/
- Select ‘Create Wallet’ and follow on-screen instructions
- Backup Keys securely
- Login to created wallet
- Go to Settings
- Select Network Configuration
- Change ‘Current Network’ to 2.X Testnet
- Download the NEON wallet - https://neonwallet.com/
- Select ‘Create Wallet’ and follow on-screen instructions
- Backup Keys securely
- Login to created wallet
- Go to Settings
- Select Network Configuration
- Change ‘Current Network’ to 2.X Testnet

### Receive NEO Testnet Tokens

- Request Testnet tokens on the NEO Discord
- Alternatively, try this faucet but it didn’t work at the time of testing - https://neowish.ngd.network/
- Request Testnet tokens on the NEO Discord
- Alternatively, try this faucet but it didn’t work at the time of testing - https://neowish.ngd.network/

## BTC

### Generate an BTC Testnet Wallet

- Visit here - https://bitcoinpaperwallet.com/bitcoinpaperwallet/generate-wallet.html?design=alt-testnet
- Follow on-screen instructions to create testnet wallet
- Backup Address and Private Key securely
- Visit here - https://bitcoinpaperwallet.com/bitcoinpaperwallet/generate-wallet.html?design=alt-testnet
- Follow on-screen instructions to create testnet wallet
- Backup Address and Private Key securely

### Receive BTC Testnet Tokens

Expand All @@ -96,15 +96,15 @@ Follow on-screen instructions to claim tokens

### Generate ETH Ropsten Address

- Install Metamask Chrome Extension - https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
- Follow on-screen instructions to create a Metamask account
- Secure passphrase safely
- Select the Ropsten Network from the Network Switcher
- Select ‘Account Details’
- Select ‘Export Private Key’
- Backup Private Key securely
- Install Metamask Chrome Extension - https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
- Follow on-screen instructions to create a Metamask account
- Secure passphrase safely
- Select the Ropsten Network from the Network Switcher
- Select ‘Account Details’
- Select ‘Export Private Key’
- Backup Private Key securely

### Receive ETH Ropsten Tokens

- Visit here - https://faucet.ropsten.be/
- Enter ETH Ropsten address to receive tokens
- Visit here - https://faucet.ropsten.be/
- Enter ETH Ropsten address to receive tokens
7 changes: 6 additions & 1 deletion packages/platform-sdk-ark/src/services/fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export class FeeService implements Contracts.FeeService {
};
}

private transform(type: string, typeGroup: number, staticFees: object, dynamicFees: object): Contracts.TransactionFee {
private transform(
type: string,
typeGroup: number,
staticFees: object,
dynamicFees: object,
): Contracts.TransactionFee {
const dynamicFee = dynamicFees[typeGroup][type];

return {
Expand Down
70 changes: 59 additions & 11 deletions packages/platform-sdk-eth/src/services/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export class TransactionService implements Contracts.TransactionService {
readonly #peer;
readonly #chain: string;
readonly #identity;
readonly #web3;

private constructor(opts: Contracts.KeyValuePair) {
this.#peer = opts.peer;
this.#chain = opts.network === "live" ? "mainnet" : "ropsten";
this.#identity = opts.identity;
this.#web3 = new Web3(""); // todo: provide a host?
}

public static async construct(opts: Contracts.KeyValuePair): Promise<TransactionService> {
Expand All @@ -30,22 +32,37 @@ export class TransactionService implements Contracts.TransactionService {
input: Contracts.TransferInput,
options?: Contracts.TransactionOptions,
): Promise<Contracts.SignedTransaction> {
const address: string = await this.#identity.address(input.sign);
const privateKey: string = input.sign.privateKey || (await this.#identity.privateKey(input.sign));

const { nonce } = await this.get(`wallets/${address}`);

const transaction = new Transaction(
{
nonce,
const senderAddress: string = await this.#identity.address().fromPassphrase(input.sign.passphrase);
const privateKey: string =
input.sign.privateKey || (await this.#identity.privateKey().fromPassphrase(input.sign.passphrase));

const { nonce } = await this.get(`wallets/${senderAddress}`);

let data: object;

if (input.contract && input.contract.address) {
const contract = await this.createContract(input.contract.address)

data = {
nonce: Web3.utils.toHex(Web3.utils.toBN(nonce).add(Web3.utils.toBN("1"))),
gasPrice: Web3.utils.toHex(4 * 1e9),
gasLimit: Web3.utils.toHex(4000000),
to: input.contract.address,
value: "0x0",
data: contract.methods.transfer(input.data.to, input.data.amount).encodeABI(),
};
} else {
data = {
nonce: Web3.utils.toHex(Web3.utils.toBN(nonce).add(Web3.utils.toBN("1"))),
gasLimit: Web3.utils.toHex(input.feeLimit),
gasPrice: Web3.utils.toHex(input.fee),
to: input.data.to,
value: Web3.utils.toHex(Web3.utils.toWei(`${input.data.amount}`, "wei")),
// data: Utils.Buffoon.fromUTF8(input.to.memo),
},
{ chain: this.#chain },
);
};
}

const transaction: Transaction = new Transaction(data, { chain: this.#chain });

transaction.sign(Utils.Buffoon.fromHex(privateKey));

Expand Down Expand Up @@ -125,4 +142,35 @@ export class TransactionService implements Contracts.TransactionService {
private async get(path: string, query?: Contracts.KeyValuePair): Promise<Contracts.KeyValuePair> {
return Utils.Http.new(this.#peer).get(path, query);
}

private async createContract(contractAddress: string) {
return new this.#web3.eth.Contract(
[
{
constant: false,
inputs: [
{
name: "_to",
type: "address",
},
{
name: "_value",
type: "uint256",
},
],
name: "transfer",
outputs: [
{
name: "success",
type: "bool",
},
],
payable: false,
stateMutability: "nonpayable",
type: "function",
},
],
contractAddress,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe("ClientService", function () {
it("should succeed", async () => {
const result = await subject.transactions({
address: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
limit: 10
limit: 10,
});

expect(result.data).toBeArray();
Expand Down
28 changes: 14 additions & 14 deletions packages/platform-sdk-xrp/__tests__/services/ledger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ const createMockService = async (record: string) => {

describe("destruct", () => {
it("should pass with a resolved transport closure", async () => {
const xrp = await createMockService("")
const xrp = await createMockService("");

await expect(xrp.destruct()).resolves.toBeUndefined();
});
});

describe("getVersion", () => {
it("should pass with an app version", async () => {
const xrp = await createMockService(ledger.appVersion.record)
const xrp = await createMockService(ledger.appVersion.record);

await expect(xrp.getVersion()).resolves.toEqual(ledger.appVersion.result);
});
});

describe("getPublicKey", () => {
it("should pass with a compressed publicKey", async () => {
const xrp = await createMockService(ledger.publicKey.record)
const xrp = await createMockService(ledger.publicKey.record);

await expect(xrp.getPublicKey(ledger.bip44.path)).resolves.toEqual(ledger.publicKey.result);
});
});

describe("signTransaction", () => {
it("should pass with a signature", async () => {
const xrp = await createMockService(ledger.transaction.record)
const xrp = await createMockService(ledger.transaction.record);

await expect(
xrp.signTransaction(ledger.bip44.path, Buffer.from(ledger.transaction.payload, "hex")),
).resolves.toEqual(ledger.transaction.result);
Expand All @@ -45,24 +45,24 @@ describe("signTransaction", () => {

describe("signTransactionWithSchnorr", () => {
it("should fail with a 'NotImplemented' error", async () => {
const xrp = await createMockService("")
const xrp = await createMockService("");

await expect(xrp.signTransactionWithSchnorr("", Buffer.alloc(0))).rejects.toThrow();
});
});

describe("signMessage", () => {
it("should fail with a 'NotImplemented' error", async () => {
const xrp = await createMockService("")
const xrp = await createMockService("");

await expect(xrp.signMessage("", Buffer.alloc(0))).rejects.toThrow();
});
});

describe("signMessageWithSchnorr", () => {
it("should fail with a 'NotImplemented' error", async () => {
const xrp = await createMockService("")
const xrp = await createMockService("");

await expect(xrp.signMessageWithSchnorr("", Buffer.alloc(0))).rejects.toThrow();
});
});
4 changes: 2 additions & 2 deletions packages/platform-sdk-xrp/src/services/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class LedgerService implements Contracts.LedgerService {

public async getVersion(): Promise<string> {
const { version } = await this.#transport.getAppConfiguration();

return version;
}

public async getPublicKey(path: string): Promise<string> {
const { publicKey } = await this.#transport.getAddress(path);

return publicKey;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/platform-sdk/src/contracts/coins/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface TransactionInput {
secondWif?: string;
privateKey?: string;
};
contract?: {
address: string;
};
}

export interface TransactionOptions {
Expand Down

0 comments on commit ddfa67f

Please sign in to comment.