-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(init): Remove connect workflow and create factory init method #33
Conversation
f9c25e8
to
765f39c
Compare
|
@@ -173,29 +173,28 @@ The SDK provides TypeScript types. When you import the SDK in a TypeScript proje | |||
|
|||
### APIs | |||
|
|||
#### `connect(signer)` | |||
#### `init({ signer })` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the comment below - mention that signer is optional. and if provided ArIOWriteable
class is returned that supports write interaction APIs; otherwise an ArIOReadable
class is returned and supports read apis only.
d745278
to
c7860ed
Compare
contract?: | ||
| (BaseContract<unknown> & ReadContract) | ||
| (BaseContract<unknown> & ReadWriteContract); | ||
contract?: WarpContract<unknown> | RemoteContract<unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be optional anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think it actually ever needed to be, since we default it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need an instance where we want to make one nullable, it can be piped thru an Omit type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it does need to be optional for a few reasons, mainly to help enable DX, however it may be prudent to create different types rather than forcing use of this one. We should talk on it, i left as is since it was simpler that way for now.
fb11d97
to
e9985dd
Compare
b069c02
to
059653c
Compare
looking good - can we add write interaction tests? |
README.md
Outdated
arIO.connect(nodeSigner); | ||
const arIOWriteable = ArIO.init({ signer: nodeSigner}); | ||
|
||
const arIOReadable = ArIO.init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this up top and add a comment
const arIOReadable = ArIO.init() | |
// read-only client that has access to all read APIs | |
const arIOReadable = ArIO.init() |
@@ -569,7 +569,7 @@ const auctions = await arIO.getAuctions({ evaluationOptions }); | |||
// } | |||
``` | |||
|
|||
#### `joinNetwork({ ...JoinNetworkParams})` | |||
#### `joinNetwork(params)` | |||
|
|||
Joins a gateway to the ar.io network via its associated wallet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add that this requires signer
to be provided on init()
- and same for the rest of them
Co-authored-by: Dylan Fiedler <dtfiedler@users.noreply.github.com>
Co-authored-by: Dylan Fiedler <dtfiedler@users.noreply.github.com>
Co-authored-by: Dylan Fiedler <dtfiedler@users.noreply.github.com>
tests/integration/ar-io.test.ts
Outdated
it('should connect and return a valid instances of read and write clients', async () => { | ||
const readClient = ArIO.init({ | ||
contract: new RemoteContract<ArIOState>({ | ||
contractTxId, | ||
cacheUrl: localCacheUrl, | ||
}), | ||
}); | ||
expect(client.connect(signer)).toBeDefined(); | ||
expect(client).toBeInstanceOf(ArIO); | ||
const writeClient = ArIO.init({ | ||
signer, | ||
contract: new WarpContract<ArIOState>({ | ||
cacheUrl: localCacheUrl, | ||
contractTxId, | ||
logger: new DefaultLogger({ level: 'none' }), | ||
}), | ||
}); | ||
expect(readClient).toBeDefined(); | ||
expect(readClient).toBeInstanceOf(ArIOReadable); | ||
expect(writeClient).toBeDefined(); | ||
expect(writeClient).toBeInstanceOf(ArIOWritable); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would separate these
//this.contract = this.contract.connect(warpSigner); | ||
//this.signer = warpSigner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//this.contract = this.contract.connect(warpSigner); | |
//this.signer = warpSigner; |
@@ -54,32 +54,26 @@ export class WarpContract<T> | |||
private logger: Logger; | |||
private warp: Warp; | |||
// warp compatible signer that uses ContractSigner | |||
private signer: CustomSignature | undefined; | |||
//private signer: CustomSignature | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//private signer: CustomSignature | undefined; |
@@ -80,6 +80,8 @@ export async function createLocalWallet( | |||
const address = await arweave.wallets.jwkToAddress(wallet); | |||
// mint some tokens | |||
await arweave.api.get(`/mint/${address}/${amount}`); | |||
const walletBalance = await arweave.wallets.getBalance(address); | |||
console.log(`Wallet balance: ${walletBalance}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(`Wallet balance: ${walletBalance}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small cleanup nits - but we can merge and finalize everything in the initial PR
🎉 This PR is included in version 1.0.0-alpha.20 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.