Skip to content

Commit

Permalink
fix(signer): remove jwk use, ignore web example for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 18, 2024
1 parent 7e08097 commit bc7e577
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ArconnectSigner, ArweaveSigner } from 'arbundles/web';
import { JWKInterface } from 'arweave/node/lib/wallet.js';
import { ArconnectSigner, ArweaveSigner } from 'arbundles';

import { ARNS_TESTNET_REGISTRY_TX } from '../constants.js';
import {
Expand All @@ -32,7 +31,6 @@ import {
SmartWeaveContract,
WeightedObserver,
} from '../types.js';
import { isJwk } from '../utils/arweave.js';
import { RemoteContract } from './contracts/remote-contract.js';

// TODO: append this with other configuration options (e.g. local vs. remote evaluation)
Expand All @@ -58,15 +56,17 @@ function isContractTxIdConfiguration(

export class ArIO implements ArIOContract {
private contract: SmartWeaveContract<ArIOState>;
signer: ArweaveSigner | ArconnectSigner | JWKInterface;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
private signer: ArweaveSigner | ArconnectSigner;

constructor({
signer,
...config
}: ContractConfiguration & {
signer: ArweaveSigner | ArconnectSigner | JWKInterface;
signer: ArweaveSigner | ArconnectSigner;
}) {
this.signer = isJwk(signer) ? new ArweaveSigner(signer) : signer;
this.signer = signer;

const isContract = isContractConfiguration<ArIOState>(config);
const isContractTxId = isContractTxIdConfiguration(config);
Expand Down
15 changes: 0 additions & 15 deletions src/utils/arweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { b64UrlToBuffer } from 'arweave/node/lib/utils.js';
import { JWKInterface } from 'arweave/node/lib/wallet.js';

import { BlockHeight } from '../common.js';
import { ARWEAVE_TX_REGEX } from '../constants.js';

Expand All @@ -27,15 +24,3 @@ export const validateArweaveId = (id: string): boolean => {
export function isBlockHeight(height: string | number): height is BlockHeight {
return height !== undefined && !isNaN(parseInt(height.toString()));
}

export const isJwk = (obj: object): obj is JWKInterface => {
let valid = true;
['n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi'].map(
(key) => !(key in obj) && (valid = false),
);
const bufferOfN = b64UrlToBuffer(obj['n']);
if (bufferOfN.length !== 512) {
valid = false;
}
return valid;
};

0 comments on commit bc7e577

Please sign in to comment.