Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ual-token-pocket",
"version": "0.3.0",
"version": "0.3.2",
"main": "dist/index.js",
"license": "MIT",
"author": {
Expand All @@ -17,11 +17,11 @@
"test": "jest"
},
"dependencies": {
"tp-eosjs": "1.5.2",
"eosjs": "^21.0.3",
"tp-eosjs": "1.7.0",
"universal-authenticator-library": "0.3.0"
},
"devDependencies": {
"@blockone/eslint-config-blockone": "^3.0.0",
"@types/jest": "^24.9.1",
"eslint": "^6.8.0",
"jest": "^24.9.0",
Expand All @@ -31,10 +31,10 @@
"description": "UAL Authenticator for Token Pocket mobile app",
"repository": {
"type": "git",
"url": "git+https://github.com/EOSIO/ual-token-pocket.git"
"url": "https://github.com/TP-Lab/ual-token-pocket.git"
},
"bugs": {
"url": "https://github.com/EOSIO/ual-token-pocket/issues"
"url": "https://github.com/TP-Lab/ual-token-pocket/issues"
},
"homepage": "https://github.com/EOSIO/ual-token-pocket#readme"
"homepage": "https://github.com/TP-Lab/ual-token-pocket#readme"
}
2 changes: 1 addition & 1 deletion src/TokenPocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class TokenPocket extends Authenticator {
}

public getOnboardingLink(): string {
return 'https://www.mytokenpocket.vip/en/'
return 'https://www.tokenpocket.pro/en/'
}

public requiresGetKeyConfirmation(): boolean {
Expand Down
39 changes: 29 additions & 10 deletions src/TokenPocketUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tp from 'tp-eosjs'
import { JsonRpc } from 'eosjs'
import {
Chain,
SignTransactionConfig,
Expand All @@ -7,24 +8,34 @@ import {
User
} from 'universal-authenticator-library'

import { EosAuthSignResponse, PushEosActionResponse, Wallet } from './interfaces'
import { PushEosActionResponse, Wallet } from './interfaces'
import { UALTokenPocketError } from './UALTokenPocketError'

export class TokenPocketUser extends User {
private wallet: Wallet
private keys: string[] = []
private chainId = ''
private accountName: string = ''
private rpc: JsonRpc | null = null

constructor(
chain: Chain | null,
wallet: Wallet
) {
super()



this.wallet = wallet
this.accountName = wallet.name

if (chain && chain.chainId) {
this.chainId = chain.chainId
const rpcEndpoint = chain.rpcEndpoints[0]
const rpcEndpointString = this.buildRpcEndpoint(rpcEndpoint)
this.rpc = new JsonRpc(rpcEndpointString)
}

}

public async signTransaction(
Expand All @@ -34,7 +45,7 @@ export class TokenPocketUser extends User {
let response: PushEosActionResponse

try {
response = await tp.pushEosAction({ ...transaction, account: this.wallet.name, address: this.wallet.address})
response = await tp.pushEosAction({ ...transaction, account: this.wallet.name, address: this.wallet.address })
if (response.result) {
return {
wasBroadcast: true,
Expand All @@ -57,15 +68,19 @@ export class TokenPocketUser extends User {
data: string,
_helpText: string
): Promise<string> {
let response: EosAuthSignResponse
let response: string

try {
response = await tp.eosAuthSign({ from: this.wallet.name, publicKey, signdata: data })
if (response.result) {
return response.data.signature
} else {
throw new Error('No result returned')
}
response = await tp.getEosArbitrarySignature({
publicKey,
data,
blockchain: 'eos',
whatfor: 'sign:' + data,
isHash: false
})
return response;


} catch (e) {
throw new UALTokenPocketError(
'Unable to sign arbitrary string',
Expand All @@ -80,13 +95,17 @@ export class TokenPocketUser extends User {
}

public async getAccountName(): Promise<string> {
return this.wallet.name
return this.accountName
}

public async getChainId(): Promise<string> {
return this.chainId
}

public async getRpc(): Promise<JsonRpc | null> {
return this.rpc
}

public async getKeys(): Promise<string[]> {
if (this.keys.length === 0) {
this.keys.push(this.wallet.address)
Expand Down
12 changes: 0 additions & 12 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,3 @@ export interface PushEosActionResponse {
transactionId: string
}
}

export interface EosAuthSignResponse {
result: boolean
data: {
signature: string
ref: string
signdata: string
timestamp: string
wallet: string
}
msg: string
}
Loading