@keystonehq/bc-ur-registry-eth
Advanced tools
Comparing version 0.7.7-alpha.0 to 0.7.7
@@ -215,4 +215,5 @@ 'use strict'; | ||
Keys[Keys["contractAddress"] = 2] = "contractAddress"; | ||
Keys[Keys["name"] = 3] = "name"; | ||
Keys[Keys["mediaData"] = 4] = "mediaData"; | ||
Keys[Keys["contractName"] = 3] = "contractName"; | ||
Keys[Keys["name"] = 4] = "name"; | ||
Keys[Keys["mediaData"] = 5] = "mediaData"; | ||
})(Keys$2 || (Keys$2 = {})); // export enum mediaType { | ||
@@ -234,2 +235,3 @@ // png = 1, | ||
this.contractAddress = args.contractAddress; | ||
this.contractName = args.contractName; | ||
this.mediaData = args.mediaData; // remove the data perfix for android usage | ||
@@ -246,2 +248,4 @@ }; | ||
this.getContractName = () => this.contractName; | ||
this.toDataItem = () => { | ||
@@ -252,2 +256,3 @@ const map = {}; | ||
map[Keys$2.contractAddress] = this.contractAddress; | ||
map[Keys$2.contractName] = this.contractName; | ||
map[Keys$2.mediaData] = this.mediaData; | ||
@@ -260,6 +265,7 @@ return new bcUrRegistry.DataItem(map); | ||
static constructETHNFTItem(chainId, contractAddress, name, mediaData) { | ||
static constructETHNFTItem(chainId, contractAddress, contractName, name, mediaData) { | ||
return new ETHNFTItem({ | ||
chainId, | ||
contractAddress, | ||
contractName, | ||
mediaData, | ||
@@ -278,2 +284,3 @@ name | ||
const contractAddress = map[Keys$2.contractAddress]; | ||
const contractName = map[Keys$2.contractName]; | ||
return new ETHNFTItem({ | ||
@@ -283,2 +290,3 @@ chainId, | ||
contractAddress, | ||
contractName, | ||
mediaData | ||
@@ -285,0 +293,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("@keystonehq/bc-ur-registry"),a=require("uuid"),s=(t=require("hdkey"))&&"object"==typeof t&&"default"in t?t.default:t,i=require("ethereumjs-util");const{RegistryType:r}=e.extend,n={ETH_SIGN_REQUEST:new r("eth-sign-request",401),ETH_SIGNATAURE:new r("eth-signature",402),ETH_NFT_ITEM:new r("eth-nft-item",403)},{decodeToDataItem:d,RegistryTypes:o}=e.extend;var h,c;!function(t){t[t.requestId=1]="requestId",t[t.signData=2]="signData",t[t.dataType=3]="dataType",t[t.chainId=4]="chainId",t[t.derivationPath=5]="derivationPath",t[t.address=6]="address",t[t.origin=7]="origin"}(h||(h={})),(c=exports.DataType||(exports.DataType={}))[c.transaction=1]="transaction",c[c.typedData=2]="typedData",c[c.personalMessage=3]="personalMessage",c[c.typedTransaction=4]="typedTransaction";class u extends e.RegistryItem{constructor(t){super(),this.getRegistryType=()=>n.ETH_SIGN_REQUEST,this.setupData=t=>{this.requestId=t.requestId,this.signData=t.signData,this.dataType=t.dataType,this.chainId=t.chainId,this.derivationPath=t.derivationPath,this.address=t.address,this.origin=t.origin},this.getRequestId=()=>this.requestId,this.getSignData=()=>this.signData,this.getDataType=()=>this.dataType,this.getChainId=()=>this.chainId,this.getDerivationPath=()=>this.derivationPath.getPath(),this.getSignRequestAddress=()=>this.address,this.getOrigin=()=>this.origin,this.toDataItem=()=>{const t={};this.requestId&&(t[h.requestId]=new e.DataItem(this.requestId,o.UUID.getTag())),this.address&&(t[h.address]=this.address),this.chainId&&(t[h.chainId]=this.chainId),this.origin&&(t[h.origin]=this.origin),t[h.signData]=this.signData,t[h.dataType]=this.dataType;const a=this.derivationPath.toDataItem();return a.setTag(this.derivationPath.getRegistryType().getTag()),t[h.derivationPath]=a,new e.DataItem(t)},this.setupData(t)}static constructETHRequest(t,s,i,r,n,d,o,h){const c=i.replace(/[m|M]\//,"").split("/"),g=new e.CryptoKeypath(c.map(t=>{const a=parseInt(t.replace("'",""));let s=!1;return t.endsWith("'")&&(s=!0),new e.PathComponent({index:a,hardened:s})}),Buffer.from(r,"hex"));return new u({requestId:n?Buffer.from(a.parse(n)):void 0,signData:t,dataType:s,derivationPath:g,chainId:d,address:o?Buffer.from(o.replace("0x",""),"hex"):void 0,origin:h||void 0})}}u.fromDataItem=t=>{const a=t.getData(),s=a[h.signData],i=a[h.dataType],r=e.CryptoKeypath.fromDataItem(a[h.derivationPath]),n=a[h.chainId]?a[h.chainId]:void 0,d=a[h.address]?a[h.address]:void 0,o=a[h.requestId]?a[h.requestId].getData():void 0;return new u({requestId:o,signData:s,dataType:i,chainId:n,derivationPath:r,address:d,origin:a[h.origin]?a[h.origin]:void 0})},u.fromCBOR=t=>{const e=d(t);return u.fromDataItem(e)};const{RegistryTypes:g,decodeToDataItem:I}=e.extend;var m;!function(t){t[t.requestId=1]="requestId",t[t.signature=2]="signature"}(m||(m={}));class p extends e.RegistryItem{constructor(t,a){super(),this.getRegistryType=()=>n.ETH_SIGNATAURE,this.getRequestId=()=>this.requestId,this.getSignature=()=>this.signature,this.toDataItem=()=>{const t={};return this.requestId&&(t[m.requestId]=new e.DataItem(this.requestId,g.UUID.getTag())),t[m.signature]=this.signature,new e.DataItem(t)},this.signature=t,this.requestId=a}}p.fromDataItem=t=>{const e=t.getData(),a=e[m.signature],s=e[m.requestId]?e[m.requestId].getData():void 0;return new p(a,s)},p.fromCBOR=t=>{const e=I(t);return p.fromDataItem(e)};const{decodeToDataItem:D}=e.extend;var T;!function(t){t[t.chainId=1]="chainId",t[t.contractAddress=2]="contractAddress",t[t.name=3]="name",t[t.mediaData=4]="mediaData"}(T||(T={}));class y extends e.RegistryItem{constructor(t){super(),this.getRegistryType=()=>n.ETH_NFT_ITEM,this.setupData=t=>{this.chainId=t.chainId,this.name=t.name,this.contractAddress=t.contractAddress,this.mediaData=t.mediaData},this.getChainId=()=>this.chainId,this.getName=()=>this.name,this.getmediaData=()=>this.mediaData,this.getContractAddress=()=>this.contractAddress,this.toDataItem=()=>{const t={};return t[T.chainId]=this.chainId,t[T.name]=this.name,t[T.contractAddress]=this.contractAddress,t[T.mediaData]=this.mediaData,new e.DataItem(t)},this.setupData(t)}static constructETHNFTItem(t,e,a,s){return new y({chainId:t,contractAddress:e,mediaData:s,name:a})}}y.fromDataItem=t=>{const e=t.getData();return new y({chainId:e[T.chainId],name:e[T.name],contractAddress:e[T.contractAddress],mediaData:e[T.mediaData]})},y.fromCBOR=t=>{const e=D(t);return y.fromDataItem(e)};const f=(t,e)=>{const a=s.fromExtendedKey(t).derive(e),r="0x"+i.publicToAddress(a.publicKey,!0).toString("hex");return i.toChecksumAddress(r)},{cbor:q}=e.extend;q.patchTags(Object.values(n).filter(t=>!!t.getTag()).map(t=>t.getTag())),Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.ETHNFTItem=y,exports.ETHSignature=p,exports.EthSignRequest=u,exports.findHDpatfromAddress=(t,e,a,s)=>{for(let i=0;i<a;i++){const a=f(e,"M/0/"+i);if(t.toLowerCase()==a.toLowerCase())return`${s}/0/${i}`}return null},exports.generateAddressfromXpub=f; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("@keystonehq/bc-ur-registry"),a=require("uuid"),s=(t=require("hdkey"))&&"object"==typeof t&&"default"in t?t.default:t,r=require("ethereumjs-util");const{RegistryType:i}=e.extend,n={ETH_SIGN_REQUEST:new i("eth-sign-request",401),ETH_SIGNATAURE:new i("eth-signature",402),ETH_NFT_ITEM:new i("eth-nft-item",403)},{decodeToDataItem:d,RegistryTypes:o}=e.extend;var h,c;!function(t){t[t.requestId=1]="requestId",t[t.signData=2]="signData",t[t.dataType=3]="dataType",t[t.chainId=4]="chainId",t[t.derivationPath=5]="derivationPath",t[t.address=6]="address",t[t.origin=7]="origin"}(h||(h={})),(c=exports.DataType||(exports.DataType={}))[c.transaction=1]="transaction",c[c.typedData=2]="typedData",c[c.personalMessage=3]="personalMessage",c[c.typedTransaction=4]="typedTransaction";class u extends e.RegistryItem{constructor(t){super(),this.getRegistryType=()=>n.ETH_SIGN_REQUEST,this.setupData=t=>{this.requestId=t.requestId,this.signData=t.signData,this.dataType=t.dataType,this.chainId=t.chainId,this.derivationPath=t.derivationPath,this.address=t.address,this.origin=t.origin},this.getRequestId=()=>this.requestId,this.getSignData=()=>this.signData,this.getDataType=()=>this.dataType,this.getChainId=()=>this.chainId,this.getDerivationPath=()=>this.derivationPath.getPath(),this.getSignRequestAddress=()=>this.address,this.getOrigin=()=>this.origin,this.toDataItem=()=>{const t={};this.requestId&&(t[h.requestId]=new e.DataItem(this.requestId,o.UUID.getTag())),this.address&&(t[h.address]=this.address),this.chainId&&(t[h.chainId]=this.chainId),this.origin&&(t[h.origin]=this.origin),t[h.signData]=this.signData,t[h.dataType]=this.dataType;const a=this.derivationPath.toDataItem();return a.setTag(this.derivationPath.getRegistryType().getTag()),t[h.derivationPath]=a,new e.DataItem(t)},this.setupData(t)}static constructETHRequest(t,s,r,i,n,d,o,h){const c=r.replace(/[m|M]\//,"").split("/"),g=new e.CryptoKeypath(c.map(t=>{const a=parseInt(t.replace("'",""));let s=!1;return t.endsWith("'")&&(s=!0),new e.PathComponent({index:a,hardened:s})}),Buffer.from(i,"hex"));return new u({requestId:n?Buffer.from(a.parse(n)):void 0,signData:t,dataType:s,derivationPath:g,chainId:d,address:o?Buffer.from(o.replace("0x",""),"hex"):void 0,origin:h||void 0})}}u.fromDataItem=t=>{const a=t.getData(),s=a[h.signData],r=a[h.dataType],i=e.CryptoKeypath.fromDataItem(a[h.derivationPath]),n=a[h.chainId]?a[h.chainId]:void 0,d=a[h.address]?a[h.address]:void 0,o=a[h.requestId]?a[h.requestId].getData():void 0;return new u({requestId:o,signData:s,dataType:r,chainId:n,derivationPath:i,address:d,origin:a[h.origin]?a[h.origin]:void 0})},u.fromCBOR=t=>{const e=d(t);return u.fromDataItem(e)};const{RegistryTypes:g,decodeToDataItem:m}=e.extend;var I;!function(t){t[t.requestId=1]="requestId",t[t.signature=2]="signature"}(I||(I={}));class p extends e.RegistryItem{constructor(t,a){super(),this.getRegistryType=()=>n.ETH_SIGNATAURE,this.getRequestId=()=>this.requestId,this.getSignature=()=>this.signature,this.toDataItem=()=>{const t={};return this.requestId&&(t[I.requestId]=new e.DataItem(this.requestId,g.UUID.getTag())),t[I.signature]=this.signature,new e.DataItem(t)},this.signature=t,this.requestId=a}}p.fromDataItem=t=>{const e=t.getData(),a=e[I.signature],s=e[I.requestId]?e[I.requestId].getData():void 0;return new p(a,s)},p.fromCBOR=t=>{const e=m(t);return p.fromDataItem(e)};const{decodeToDataItem:D}=e.extend;var T;!function(t){t[t.chainId=1]="chainId",t[t.contractAddress=2]="contractAddress",t[t.contractName=3]="contractName",t[t.name=4]="name",t[t.mediaData=5]="mediaData"}(T||(T={}));class y extends e.RegistryItem{constructor(t){super(),this.getRegistryType=()=>n.ETH_NFT_ITEM,this.setupData=t=>{this.chainId=t.chainId,this.name=t.name,this.contractAddress=t.contractAddress,this.contractName=t.contractName,this.mediaData=t.mediaData},this.getChainId=()=>this.chainId,this.getName=()=>this.name,this.getmediaData=()=>this.mediaData,this.getContractAddress=()=>this.contractAddress,this.getContractName=()=>this.contractName,this.toDataItem=()=>{const t={};return t[T.chainId]=this.chainId,t[T.name]=this.name,t[T.contractAddress]=this.contractAddress,t[T.contractName]=this.contractName,t[T.mediaData]=this.mediaData,new e.DataItem(t)},this.setupData(t)}static constructETHNFTItem(t,e,a,s,r){return new y({chainId:t,contractAddress:e,contractName:a,mediaData:r,name:s})}}y.fromDataItem=t=>{const e=t.getData();return new y({chainId:e[T.chainId],name:e[T.name],contractAddress:e[T.contractAddress],contractName:e[T.contractName],mediaData:e[T.mediaData]})},y.fromCBOR=t=>{const e=D(t);return y.fromDataItem(e)};const f=(t,e)=>{const a=s.fromExtendedKey(t).derive(e),i="0x"+r.publicToAddress(a.publicKey,!0).toString("hex");return r.toChecksumAddress(i)},{cbor:q}=e.extend;q.patchTags(Object.values(n).filter(t=>!!t.getTag()).map(t=>t.getTag())),Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.ETHNFTItem=y,exports.ETHSignature=p,exports.EthSignRequest=u,exports.findHDpatfromAddress=(t,e,a,s)=>{for(let r=0;r<a;r++){const a=f(e,"M/0/"+r);if(t.toLowerCase()==a.toLowerCase())return`${s}/0/${r}`}return null},exports.generateAddressfromXpub=f; | ||
//# sourceMappingURL=bc-ur-registry-eth.cjs.production.min.js.map |
@@ -212,4 +212,5 @@ import { extend, RegistryItem, DataItem, CryptoKeypath, PathComponent } from '@keystonehq/bc-ur-registry'; | ||
Keys[Keys["contractAddress"] = 2] = "contractAddress"; | ||
Keys[Keys["name"] = 3] = "name"; | ||
Keys[Keys["mediaData"] = 4] = "mediaData"; | ||
Keys[Keys["contractName"] = 3] = "contractName"; | ||
Keys[Keys["name"] = 4] = "name"; | ||
Keys[Keys["mediaData"] = 5] = "mediaData"; | ||
})(Keys$2 || (Keys$2 = {})); // export enum mediaType { | ||
@@ -231,2 +232,3 @@ // png = 1, | ||
this.contractAddress = args.contractAddress; | ||
this.contractName = args.contractName; | ||
this.mediaData = args.mediaData; // remove the data perfix for android usage | ||
@@ -243,2 +245,4 @@ }; | ||
this.getContractName = () => this.contractName; | ||
this.toDataItem = () => { | ||
@@ -249,2 +253,3 @@ const map = {}; | ||
map[Keys$2.contractAddress] = this.contractAddress; | ||
map[Keys$2.contractName] = this.contractName; | ||
map[Keys$2.mediaData] = this.mediaData; | ||
@@ -257,6 +262,7 @@ return new DataItem(map); | ||
static constructETHNFTItem(chainId, contractAddress, name, mediaData) { | ||
static constructETHNFTItem(chainId, contractAddress, contractName, name, mediaData) { | ||
return new ETHNFTItem({ | ||
chainId, | ||
contractAddress, | ||
contractName, | ||
mediaData, | ||
@@ -275,2 +281,3 @@ name | ||
const contractAddress = map[Keys$2.contractAddress]; | ||
const contractName = map[Keys$2.contractName]; | ||
return new ETHNFTItem({ | ||
@@ -280,2 +287,3 @@ chainId, | ||
contractAddress, | ||
contractName, | ||
mediaData | ||
@@ -282,0 +290,0 @@ }); |
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
contractAddress: string; | ||
contractName: string; | ||
name: string; | ||
@@ -14,2 +15,3 @@ mediaData: string; | ||
private contractAddress; | ||
private contractName; | ||
private mediaData; | ||
@@ -23,7 +25,8 @@ getRegistryType: () => import("@keystonehq/bc-ur-registry/src/RegistryType").RegistryType; | ||
getContractAddress: () => string; | ||
getContractName: () => string; | ||
toDataItem: () => DataItem; | ||
static fromDataItem: (dataItem: any) => ETHNFTItem; | ||
static fromCBOR: (_cborPayload: Buffer) => ETHNFTItem; | ||
static constructETHNFTItem(chainId: number, contractAddress: string, name: string, mediaData: string): ETHNFTItem; | ||
static constructETHNFTItem(chainId: number, contractAddress: string, contractName: string, name: string, mediaData: string): ETHNFTItem; | ||
} | ||
export {}; |
@@ -16,3 +16,3 @@ /// <reference types="node" /> | ||
address?: Buffer; | ||
origin?: String; | ||
origin?: string; | ||
}; | ||
@@ -36,3 +36,3 @@ export declare class EthSignRequest extends RegistryItem { | ||
getSignRequestAddress: () => Buffer; | ||
getOrigin: () => String; | ||
getOrigin: () => string; | ||
toDataItem: () => DataItem; | ||
@@ -39,0 +39,0 @@ static fromDataItem: (dataItem: any) => EthSignRequest; |
{ | ||
"name": "@keystonehq/bc-ur-registry-eth", | ||
"version": "0.7.7-alpha.0", | ||
"version": "0.7.7", | ||
"description": "bc-ur-registry extension for ETH", | ||
@@ -37,3 +37,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "2c2dacb28325054e81d673d033bf754e8e8170ad" | ||
"gitHead": "3da553401363b9c96830abc58ce5a5f2f76188f7" | ||
} |
@@ -9,2 +9,3 @@ import { extend, DataItem, RegistryItem } from '@keystonehq/bc-ur-registry'; | ||
contractAddress = 2, | ||
contractName, | ||
name, | ||
@@ -16,9 +17,9 @@ mediaData, | ||
chainId: number; | ||
contractAddress:string, | ||
name: string, | ||
mediaData: string, | ||
contractAddress: string; | ||
contractName: string; | ||
name: string; | ||
mediaData: string; | ||
// mediaType: mediaType | ||
} | ||
}; | ||
// export enum mediaType { | ||
@@ -33,2 +34,3 @@ // png = 1, | ||
private contractAddress: string; | ||
private contractName: string; | ||
private mediaData: string; | ||
@@ -47,4 +49,4 @@ | ||
this.contractAddress = args.contractAddress; | ||
this.contractName = args.contractName; | ||
this.mediaData = args.mediaData; // remove the data perfix for android usage | ||
}; | ||
@@ -56,3 +58,4 @@ | ||
public getContractAddress = () => this.contractAddress; | ||
public getContractName = () => this.contractName; | ||
public toDataItem = () => { | ||
@@ -63,2 +66,3 @@ const map = {}; | ||
map[Keys.contractAddress] = this.contractAddress; | ||
map[Keys.contractName] = this.contractName; | ||
map[Keys.mediaData] = this.mediaData; | ||
@@ -75,2 +79,3 @@ | ||
const contractAddress = map[Keys.contractAddress]; | ||
const contractName = map[Keys.contractName]; | ||
@@ -81,2 +86,3 @@ return new ETHNFTItem({ | ||
contractAddress, | ||
contractName, | ||
mediaData, | ||
@@ -94,14 +100,14 @@ }); | ||
contractAddress: string, | ||
contractName: string, | ||
name: string, | ||
mediaData: string | ||
mediaData: string, | ||
) { | ||
return new ETHNFTItem({ | ||
chainId, | ||
contractAddress, | ||
contractName, | ||
mediaData, | ||
name | ||
name, | ||
}); | ||
} | ||
} |
@@ -14,3 +14,3 @@ import { CryptoKeypath, extend, DataItem, PathComponent, RegistryItem } from '@keystonehq/bc-ur-registry'; | ||
address, | ||
origin | ||
origin, | ||
} | ||
@@ -32,3 +32,3 @@ | ||
address?: Buffer; | ||
origin?: String; | ||
origin?: string; | ||
}; | ||
@@ -43,3 +43,3 @@ | ||
private address: Buffer; | ||
private origin: String; | ||
private origin: string; | ||
@@ -83,3 +83,3 @@ getRegistryType = () => ExtendedRegistryTypes.ETH_SIGN_REQUEST; | ||
if(this.origin) { | ||
if (this.origin) { | ||
map[Keys.origin] = this.origin; | ||
@@ -115,3 +115,3 @@ } | ||
address, | ||
origin | ||
origin, | ||
}); | ||
@@ -118,0 +118,0 @@ }; |
@@ -7,3 +7,3 @@ import { extend } from '@keystonehq/bc-ur-registry'; | ||
ETH_SIGNATAURE: new RegistryType('eth-signature', 402), | ||
ETH_NFT_ITEM: new RegistryType('eth-nft-item', 403) | ||
ETH_NFT_ITEM: new RegistryType('eth-nft-item', 403), | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97147
946