Skip to content

Commit

Permalink
Merge pull request #165 from CirclesUBI/pathfinder-api-call
Browse files Browse the repository at this point in the history
Modify findTransitiveTransfer to call the pathfinder service
  • Loading branch information
llunaCreixent authored Mar 21, 2023
2 parents c80e8ca + 0208539 commit 57d47dc
Show file tree
Hide file tree
Showing 12 changed files with 657 additions and 388 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ RPC_URL=http://localhost:8545
# Service Endpoints
API_SERVICE_ENDPOINT=http://api.circles.local
GRAPH_NODE_ENDPOINT=http://graph.circles.local
PATHFINDER_SERVICE_ENDPOINT=http://localhost:8081
RELAY_SERVICE_ENDPOINT=http://relay.circles.local

# Database Endpoints
# Database Endpoint
DATABASE_SOURCE=graph

# Pathfinder Type cli or server
PATHFINDER_TYPE=server

# Smart Contract addresses of 1.3.0 version
HUB_ADDRESS=0xCfEB869F69431e42cdB54A4F4f105C19C080A601
PROXY_FACTORY_ADDRESS=0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ jobs:
working-directory: circles-docker
run: cp .env.example .env

- name: Container setup via docker-compose
- name: Container setup via docker-compose without pathfinder
working-directory: circles-docker
run: docker-compose -f docker-compose.yml -f docker-compose.relayer-pull.yml -f docker-compose.api-pull.yml -p circles up --detach --remove-orphans --build
run: docker compose -f docker-compose.yml -f docker-compose.relayer-pull.yml -f docker-compose.api-pull.yml -p circles up --detach --remove-orphans --build

- name: Download and migrate contracts
working-directory: circles-docker
Expand All @@ -70,7 +70,11 @@ jobs:

- name: Try starting failed services
working-directory: circles-docker
run: docker-compose -f docker-compose.yml -f docker-compose.relayer-pull.yml -f docker-compose.api-pull.yml -p circles up --detach --remove-orphans --build
run: docker compose -f docker-compose.yml -f docker-compose.relayer-pull.yml -f docker-compose.api-pull.yml -p circles up --detach --remove-orphans --build

- name: Container setup via docker-compose for pathfinder
working-directory: circles-docker
run: docker compose -f docker-compose.pathfinder-pull.yml -p circles up --detach --build

- name: Install dependencies
working-directory: circles-core
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const core = new CirclesCore(web3, {
proxyFactoryAddress: '0x9b1f7F645351AF3631a656421eD2e40f2802E6c0',
safeMasterAddress: '0x59d3631c86BbE35EF041872d502F218A39FBa150',
apiServiceEndpoint: 'http://api.circles.local',
pathfinderServiceEndpoint: 'http://pathfinder.circles.local'
pathfinderType: 'server',
graphNodeEndpoint: 'http://graph.circles.local',
databaseSource: 'graph',
relayServiceEndpoint: 'http://relay.circles.local',
Expand Down
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default class CirclesCore {
* @param {Web3} web3 - instance of Web3
* @param {Object} options - global core options
* @param {string} options.apiServiceEndpoint - URL of the username resolver service
* @param {string} options.pathfinderServiceEndpoint - URL of the pathfinder service
* @param {string} options.pathfinderType - Type of pathfinder used to get transfer steps ("cli" or "server")
* @param {string} options.databaseSource - database source type
* @param {string} options.fallbackHandlerAddress - address of the fallback handler of the Safe contract
* @param {string} options.graphNodeEndpoint - URL of the graph node
Expand Down Expand Up @@ -67,12 +69,19 @@ export default class CirclesCore {
apiServiceEndpoint: {
type: 'string',
},
pathfinderServiceEndpoint: {
type: 'string',
},
relayServiceEndpoint: {
type: 'string',
},
subgraphName: {
type: 'string',
},
pathfinderType: {
type: 'string',
default: 'server',
},
});

// Expose error classes and constants
Expand Down Expand Up @@ -110,7 +119,12 @@ export default class CirclesCore {
this.options,
);
/** @type {Object} - token module */
this.token = createTokenModule(web3, this.contracts, this.utils);
this.token = createTokenModule(
web3,
this.contracts,
this.utils,
this.options,
);
/** @type {Object} - trust module */
this.trust = createTrustModule(web3, this.contracts, this.utils);
/** @type {Object} - user module */
Expand Down
12 changes: 12 additions & 0 deletions src/safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getSafeContract,
getSafeCRCVersionContract,
} from '~/common/getContracts';
import loop from '~/common/loop';

/**
* Helper method to receive a list of all Gnosis Safe owners.
Expand Down Expand Up @@ -546,6 +547,17 @@ export default function createSafeModule(
`Safe with version ${safeVersion} failed to change the Master Copy`,
);
}

// Wait to check that the version is updated
await loop(
() => {
return getVersion(web3, options.safeAddress);
},
(version) => {
return version == SAFE_LAST_VERSION;
},
);

// Then we setup the fallbackHandler
const fallbackHandlerTxData = safeInstance.methods
.setFallbackHandler(fallbackHandlerAddress)
Expand Down
Loading

0 comments on commit 57d47dc

Please sign in to comment.