0.6.1 • Published 12 months ago

@prifilabs/shield-ethereum-js v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

The Shield

API

Core functions

  • getDefaultFactory(signer: ethers.Signer, network: string): Promise<ethers.Contract>: returns the Shield Factory contract deployed on network
  • createShield(signer: ethers.Signer, name: string, roles: any[], users: any[], policy: any[], factory: ethers.Contract): Promise<{receipt: ethers.Transaction, shield: Shield}>: deploys a shield and returns the corresponding shield object (see below)
  • instantiateShield(signer: ethers.Signer, address: string): Promise<Shield>: returns a shield object (see below) of an existing deployed shield at address
  • getShields(signer: ethers.Signer, factory: ethers.Contract): Promise<{ [address: string]: string }>: returns the list of shield's addresses for which the user address is one of the users

Methods of the Shield object

Shield getters

  • getRoles(): Promise<string[]>
  • getUsers(): Promise<{[address: string]: string[]}>
  • getUser(address: string): Promise<string[]>
  • getPolicies(): Promise<{[label: string]: string[][]}>
  • getPolicy(label: string): Promise<string[][]>
  • getAssignedPolicies(): Promise<{[address: string]: {[func: string]: string}}>
  • getAssignedPolicy(to: string, func: string): Promise<string>
  • isPaused(): Promise<boolean>
  • getTransactionHash(credentials: Credentials): Promise<string>

Handling Shieldables

  • getShieldables(): Promise<string[]>
  • addInterface(address: string, iface: ethers.utils.Interface)
  • getInterface(address: string): Promise<ethers.utils.Interface>

Handling Credentials

  • getCredentials(): Promise<Array<Credentials>>
  • createCredentials(to: string, func: string, args: any[]): Promise<Credentials>: returns a new credentials to call the function func from the contract to with the args args.
  • approveCredentials(credentials: Credentials): Promise<Credentials>: returns a newly approved credentials
  • checkCredentials(credentials: Credentials, full?: boolean):Promise<{to: string, func: string, args:any[], timestamp:number, approvals: string[]}>
  • executeCredentials(credentials: Credentials) execute the credentials
  • cancelCredentials(credentials: Credentials): Promise<ethers.Transaction>
  • isExecuted(credentials: Credentials):Promise<boolean>
  • isCanceled(credentials: Credentials):Promise<boolean>

createCredentials wrappers

  • createCredentialsForAddRoles(roles: string[]): Promise<Credentials>
  • createCredentialsForSetUsers(users: Array<{ address: string; roles: string[] }>): Promise<Credentials>
  • createCredentialsForAddPolicy(label: string, policy: string[][]): Promise<Credentials>
  • createCredentialsForAssignPolicy(to: address, func: string, label: string)
  • createCredentialsForPause(): Promise<Credentials>
  • createCredentialsForUnpause()

Utils

  • Utils.signData(signer: Signer, types: string[], values: any[])
  • Utils.getSigner(types: string[], values: any[], signature: string)
  • Utils.encodeCredentials(credentials: Credentials): string: returns the base-64 encoded version of credentials
  • Utils.decodeCredentials(encodedCredentials: string): Credential returns the decoded credentials of the base-64 encoded string
  • Utils.getSignature(func, iface)
  • Utils.getFunction(sig, iface)
  • Utils.encodeCallData(func, args, iface)
  • Utils.decodeCallData(call, iface)
  • Utils.getBytesFromRoles(roles: any[], allRoles: any[])
  • Utils.getRolesFromBytes(bytes: any, allRoles: any[])
0.6.1

12 months ago

0.6.0

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago