Make Wallet first-class citizens (#3990)
* Fixed hint in Address Select + Wallet as first-class-citizen * Separate Owned and not Owned Wallets * Fix balance not updating * Fix MethodDecoding for Contract Deployment * Fix TypedInput params * Fix Token Transfer for Wallet * Small change to contracts * Fix wallets shown twice * Fix separation of accounts and wallets in Accounts * Fix linting * Execute contract methods from Wallet ✓ * Fixing linting * Wallet as first-class citizen: Part 1 (Manual) #3784 * Lower level wallet transaction convertion * Fix linting * Proper autoFocus on right Signer input * PR Grumble: don't show Wallets in dApps Permissions * Add postTransaction and gasEstimate wrapper methods * Extract Wallet postTx and gasEstimate to utils + PATCH api * Remove invalid test It's totally valid for input's length not to be a multiple of 32 bytes. EG. for Wallet Contracts * Merge master * Fix linting * Fix merge issue * Rename Portal * Rename Protal => Portal (typo)
This commit is contained in:
committed by
Gav Wood
parent
88c0329a31
commit
fd41a10319
@@ -25,7 +25,7 @@ export default class Encoder {
|
||||
throw new Error('tokens should be array of Token');
|
||||
}
|
||||
|
||||
const mediates = tokens.map((token) => Encoder.encodeToken(token));
|
||||
const mediates = tokens.map((token, index) => Encoder.encodeToken(token, index));
|
||||
const inits = mediates
|
||||
.map((mediate, idx) => mediate.init(Mediate.offsetFor(mediates, idx)))
|
||||
.join('');
|
||||
@@ -36,37 +36,40 @@ export default class Encoder {
|
||||
return `${inits}${closings}`;
|
||||
}
|
||||
|
||||
static encodeToken (token) {
|
||||
static encodeToken (token, index = 0) {
|
||||
if (!isInstanceOf(token, Token)) {
|
||||
throw new Error('token should be instanceof Token');
|
||||
}
|
||||
|
||||
switch (token.type) {
|
||||
case 'address':
|
||||
return new Mediate('raw', padAddress(token.value));
|
||||
try {
|
||||
switch (token.type) {
|
||||
case 'address':
|
||||
return new Mediate('raw', padAddress(token.value));
|
||||
|
||||
case 'int':
|
||||
case 'uint':
|
||||
return new Mediate('raw', padU32(token.value));
|
||||
case 'int':
|
||||
case 'uint':
|
||||
return new Mediate('raw', padU32(token.value));
|
||||
|
||||
case 'bool':
|
||||
return new Mediate('raw', padBool(token.value));
|
||||
case 'bool':
|
||||
return new Mediate('raw', padBool(token.value));
|
||||
|
||||
case 'fixedBytes':
|
||||
return new Mediate('raw', padFixedBytes(token.value));
|
||||
case 'fixedBytes':
|
||||
return new Mediate('raw', padFixedBytes(token.value));
|
||||
|
||||
case 'bytes':
|
||||
return new Mediate('prefixed', padBytes(token.value));
|
||||
case 'bytes':
|
||||
return new Mediate('prefixed', padBytes(token.value));
|
||||
|
||||
case 'string':
|
||||
return new Mediate('prefixed', padString(token.value));
|
||||
case 'string':
|
||||
return new Mediate('prefixed', padString(token.value));
|
||||
|
||||
case 'fixedArray':
|
||||
case 'array':
|
||||
return new Mediate(token.type, token.value.map((token) => Encoder.encodeToken(token)));
|
||||
|
||||
default:
|
||||
throw new Error(`Invalid token type ${token.type} in encodeToken`);
|
||||
case 'fixedArray':
|
||||
case 'array':
|
||||
return new Mediate(token.type, token.value.map((token) => Encoder.encodeToken(token)));
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Cannot encode token #${index} [${token.type}: ${token.value}]. ${e.message}`);
|
||||
}
|
||||
|
||||
throw new Error(`Invalid token type ${token.type} in encodeToken`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user