Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #91 from onflow/mackenzie/update-fcl
Browse files Browse the repository at this point in the history
Removes sdk, updates authz.
  • Loading branch information
10thfloor authored May 26, 2021
2 parents 0e474bf + f7542b4 commit d5f9685
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 68 deletions.
20 changes: 10 additions & 10 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@onflow/fcl": "0.0.69",
"@onflow/sdk": "0.0.45",
"@onflow/fcl": "0.0.70",
"@onflow/types": "0.0.4",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
Expand Down
11 changes: 4 additions & 7 deletions api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function getConfig() {

const accessApi = process.env.FLOW_ACCESS_NODE;

const minterAddress = fcl.withPrefix(process.env.MINTER_ADDRESS!);
const minterAddress = process.env.MINTER_ADDRESS!;
const minterPrivateKeyHex = process.env.MINTER_PRIVATE_KEY!;

if (!process.env.MINTER_ADDRESS || !process.env.MINTER_PRIVATE_KEY) {
Expand All @@ -40,12 +40,9 @@ export function getConfig() {

const minterAccountKeyIndex = process.env.MINTER_ACCOUNT_KEY_INDEX || 0;

const fungibleTokenAddress = fcl.withPrefix(
process.env.FUNGIBLE_TOKEN_ADDRESS!
);
const nonFungibleTokenAddress = fcl.withPrefix(
process.env.NON_FUNGIBLE_TOKEN_ADDRESS!
);
const fungibleTokenAddress = process.env.FUNGIBLE_TOKEN_ADDRESS!;

const nonFungibleTokenAddress = process.env.NON_FUNGIBLE_TOKEN_ADDRESS!;

const databaseUrl = process.env.DATABASE_URL!;

Expand Down
37 changes: 16 additions & 21 deletions api/src/services/flow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fcl from "@onflow/fcl";
import * as sdk from "@onflow/sdk";

import { ec as EC } from "elliptic";

Expand All @@ -18,26 +17,22 @@ class FlowService {
return async (account: any = {}) => {
const user = await this.getAccount(this.minterFlowAddress);
const key = user.keys[this.minterAccountIndex];
let sequenceNum;
if (account.role.proposer) {
sequenceNum = key.sequenceNumber;
}
const signingFunction = async (data) => {
return {
addr: user.address,
keyId: key.index,
signature: this.signWithKey(this.minterPrivateKeyHex, data.message),
};
};

const sign = this.signWithKey;
const pk = this.minterPrivateKeyHex;

return {
...account,
addr: user.address,
keyId: key.index,
sequenceNum,
signature: account.signature || null,
signingFunction,
resolve: null,
roles: account.roles,
tempId: `${user.address}-${key.index}`,
addr: fcl.sansPrefix(user.address),
keyId: Number(key.index),
signingFunction: (signable) => {
return {
addr: fcl.withPrefix(user.address),
keyId: Number(key.index),
signature: sign(pk, signable.message),
};
},
};
};
};
Expand Down Expand Up @@ -88,8 +83,8 @@ class FlowService {
}

async getLatestBlockHeight() {
const block = await sdk.send(await sdk.build([sdk.getBlock(true)]));
const decoded = await sdk.decode(block);
const block = await fcl.send([fcl.getBlock(true)]);
const decoded = await fcl.decode(block);
return decoded.height;
}
}
Expand Down
5 changes: 2 additions & 3 deletions api/src/workers/base-event-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fcl from "@onflow/fcl";
import * as sdk from "@onflow/sdk";

import { BlockCursor } from "../models/block-cursor";
import { BlockCursorService } from "../services/block-cursor";
Expand Down Expand Up @@ -52,8 +51,8 @@ abstract class BaseEventHandler {

if (fromBlock <= toBlock) {
try {
const result = await sdk.send([
sdk.getEvents(eventName, fromBlock, toBlock),
const result = await fcl.send([
fcl.getEventsAtBlockHeightRange(eventName, fromBlock, toBlock),
]);
const decoded = await fcl.decode(result);

Expand Down
30 changes: 6 additions & 24 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"@emotion/react": "^11.1.4",
"@emotion/styled": "^11.0.0",
"@onflow/fcl": "0.0.70",
"@onflow/sdk": "0.0.46",
"@onflow/types": "^0.0.4",
"@onflow/util-actor": "^0.0.2",
"@onflow/util-invariant": "^0.0.0",
Expand Down

0 comments on commit d5f9685

Please sign in to comment.